SDWebImage Cancel download

非 Y 不嫁゛ 提交于 2019-12-05 10:52:48

In your cell, you can cancel the image load if it's going to get re-used. In your UITableViewCell subclass add the following:

-(void)prepareForReuse {
    [super prepareForReuse];
    [self.imageView cancelCurrentImageLoad]; // UIImageView for whatever image you need to cancel the loading for
}

Be sure to #import "UIImageView+WebCache.h" as well.

Though your app shouldn't be crashing, but I cannot help you without seeing some code, since it's not possible to pinpoint the cause of the crash from your description above.

 - (void)cancelAll
{
    for (SDWebImageDownloader *downloader in downloaders) {
    [downloader cancel];
    }
    [cacheDelegates removeAllObjects];
    [cacheURLs removeAllObjects];

    [downloadInfo removeAllObjects];
    [downloadDelegates removeAllObjects];
    [downloaders removeAllObjects];
    [downloaderForURL removeAllObjects];
}
amit_donga

Put this line of code when your SDWebImage is already loaded:

[self.imageView cancelCurrentImageLoad];

SWIFT 4.0

self.imageView.sd_cancelCurrentImageLoad()

In case you are using SDWebImage Activity Indicator and wants to remove that as well

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