Show activity indicator in SDWebImage

前端 未结 18 1380
独厮守ぢ
独厮守ぢ 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 10:01

    My list is quite lag when the user scrolling the list up and down repeatedly. I found out that the activityindicator had been added infinitely when the cellForItemAtIndexPath is being repeatedly called.

    To solve this, add a tag at your activityindicator:

    activityIndicator.tag = 9999;
    

    Before the UIActivityIndicator is being created, add these lines to remove the previous activityindicator before adding the new one:

    UIView* toDeleteLoader = [cell viewWithTag:9999];
    if(toDeleteLoader != nil){
        [toDeleteLoader removeFromSuperview];
    }
    

    Note: tag content can be any numbers that it won't be used in your cell.

提交回复
热议问题