I have a UITableViewCell which has 2 UIImageView defined in xib file.
Now I came with idea to beautify the ui and I would like to change runtime the UIImageView with UIActivityIndicatorView until the async response doesn't come back.
Unfortunately the UIActivityIndicatorView it isn't visible at all, just the complete image when finished.
Here is the relavant code part:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:myTableCellId];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
...
UIImageView *imageView = (UIImageView *)[cell viewWithTag:200];
...
imageView.image=nil; // reset image as it will be retrieved asychronously
UIActivityIndicatorView *loadingActivity = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[loadingActivity startAnimating];
loadingActivity.frame = imageView.frame;
UIView* parent = [imageView superview];
[parent addSubview:loadingActivity];
[parent bringSubviewToFront:loadingActivity];
[myObject callMyFunction:index completionBlock:^(UIImage *img) {
dispatch_async(dispatch_get_main_queue(), ^{
imageView.image=img;
[loadingActivity stopAnimating];
[loadingActivity removeFromSuperview];
//DLog(@"Got image for: %@", titleLabel.text);
});
}];
return cell;
}
Any ideas what is wrong?
If you have a white spinner on a white background, it won't appear to be visible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With