I\'m using SDWebView image and i want to show an Activity Indicator as placeholder, while fetching the image from remote.
I tried Malek\'s answer here How to show an act
The above code is slightly wrong. The line 'activityIndicator.center = imageView.center' does not give you the correct coordinates to center the progress view. For me, it was showing the indicator below the cell.
Note - I am using the latest version of the SDWebImage code so the method is slightly different. I am also using a UIButton for the imageView
Try this:
NSURL *url = [NSURL URLWithString:@"www.someimageurl.com"];
__block UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.frame = cell.imageView.bounds;
[cell.imageView addSubview:activityIndicator];
[activityIndicator startAnimating];
[cell.imageView setImageWithURL:url forState:UIControlStateNormal completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
[activityIndicator removeFromSuperview];
}];