Do not init an activity indictor if image isn't downloading in demo app (good practice)
This commit is contained in:
parent
a7af2a19e4
commit
1ec36c7c99
|
@ -33,13 +33,20 @@
|
|||
{
|
||||
if (self.imageURL)
|
||||
{
|
||||
UIActivityIndicatorView *activityIndicator;
|
||||
[self.imageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
|
||||
activityIndicator.center = self.imageView.center;
|
||||
[activityIndicator startAnimating];
|
||||
[self.imageView setImageWithURL:self.imageURL placeholderImage:nil options:SDWebImageProgressiveDownload completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)
|
||||
__block UIActivityIndicatorView *activityIndicator;
|
||||
[self.imageView setImageWithURL:self.imageURL placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSUInteger receivedSize, long long expectedSize)
|
||||
{
|
||||
if (!activityIndicator)
|
||||
{
|
||||
[self.imageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
|
||||
activityIndicator.center = self.imageView.center;
|
||||
[activityIndicator startAnimating];
|
||||
}
|
||||
}
|
||||
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)
|
||||
{
|
||||
[activityIndicator removeFromSuperview];
|
||||
activityIndicator = nil;
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue