I am using SDWebimage to load images on my tablkeview I am following this tutorial
Now I stuck on a problem,If I scroll down and hit back before images get loaded the app got crashes.How can I solve this ?
How to cancel the SDWebImage download. I have gone through some answers and discussions.But none of them helped me and could not use them
Please help me
I am using
[cell.UserImage setImageWithURL:[NSURL URLWithString:[SDWebArray objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:@"Placeholder.png"]];
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.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With