I have a UITableViewCell that has 2 UIImageView defined in an xib file. Now I came up with the idea to decorate ui, and I would like to change the runtime of UIImageView with UIActivityIndicatorView until the asynchronous response returns.
Unfortunately, UIActivityIndicatorView does not display it at all, just the full image when it is finished.
Here is the piece of code that is relevant:
-(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?
user529543
source share