I have a horizontal collection view and it has 20 cells with UIImageView I just want to show the activity indicator till the image download completed. I am using the new SDWebImage library where we have methods as sd_setImageWithURL Till now What i am doing is
__block UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.center = cell.photoOneImageView.center;
activityIndicator.hidesWhenStopped = YES;
[cell.photoOneImageView sd_setImageWithURL:[NSURL URLWithString:@"https://scontent-sjc.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/p480x480/11073324_10153728863852926_4010319763478440264_n.jpg?oh=590934059508b7da235a46fc39e08063&oe=55B61458"]
placeholderImage:[UIImage imageNamed:@"placeholder.jpg"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[activityIndicator stopAnimating];
[activityIndicator removeFromSuperview];
}];
[cell.photoOneImageView addSubview:activityIndicator];
[activityIndicator startAnimating];
I am writing this code in cellForItemAtIndexPath method It shows sometimes multiple indicators on 1 cell and they are not removing also sometimes when we scroll the collection view horizontally.
I saw this https://github.com/rs/SDNetworkActivityIndicator but I am unable to use this. No luck with that. Has anyone implemented activity indicator in tebleview cell or collection view cell when the image completed the indicator vanish. Please help. Any help will be appreciated. Thanks