Show activity indicator in SDWebImage

前端 未结 18 1425
独厮守ぢ
独厮守ぢ 2021-01-30 09:20

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

18条回答
  •  佛祖请我去吃肉
    2021-01-30 09:44

    I believe with the latest version of sdwebimage this is a better method.

    [self.customImageView setImageWithURL:imageURL
                                 placeholderImage:nil
                                          options:nil
                                         progress:^(NSUInteger receivedSize, long long expectedSize) { [self.activityIndicator startAnimating]; }
                                        completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { [self.activityIndicator stopAnimating]; }];
    

    Note: If you don't have a property setup obviously self.activityindicator won't work.

    I would use Michael Frederick's example to create the activityindicator instead.

提交回复
热议问题