Is there any way to stop an image in a UIImageView from lazy loading with SDWebImage on iOS?

与世无争的帅哥 提交于 2019-12-11 08:58:14

问题


I'm using the following code to lazy load an image into my UIImageView:

[self.imv1 setImageWithURL:[NSURL URLWithString:myURL]
              placeholderImage:[UIImage imageNamed:@"loading.png"]
                     completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)
     {
         // stuff here
     }];

When a user touches a button, I want the lazy loading of this to STOP completely, so that no image gets loaded and the download of the image stops.

After I stop the lazy loading, I plan to load a different image into the same UIImageView.

Is this possible with SDWebImage?


回答1:


Found out how to do it. I just needed to call this:

[self.imv1 cancelCurrentImageLoad];


来源:https://stackoverflow.com/questions/17073240/is-there-any-way-to-stop-an-image-in-a-uiimageview-from-lazy-loading-with-sdwebi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!