I am using https://github.com/rs/SDWebImage to load images in a UITableView. Here is how i implemented it (simple), inside cellForRowAtIndexPath
[cell.imageView setImageWithURL:[NSURL URL开发者_Go百科WithString:[item valueForKey:@"icon"]]placeholderImage:[UIImage imageNamed:@"icon_events_default.png"]];
After images are loaded in UITableView, i scroll down, and than again up, and i receive error:EXC_BAD_ACCESS
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
{
SDWebImageManager *manager = [SDWebImageManager sharedManager];
// Remove in progress downloader from queue
[manager cancelForDelegate:self];
UIImage *cachedImage = [manager imageWithURL:url];
if (cachedImage)
{
//EXC_BAD_ACCESS hapens here
self.image = cachedImage;
}
else
{
if (placeholder)
{
self.image = placeholder;
}
[manager downloadWithURL:url delegate:self];
}
}
Any help is really appreciated.
Did you run this code through Zombies in Instruments? That should point to the problem immediately. Just select Profile from the Product menu, Instruments will start, select the Zombie instrument, then run the test scenario which causes this problem, and you should see a zombie pop up that shows how an object is still being used even though it's no longer valid.
If I had to guess, you're UITableViewCell is not being properly retained and it's either getting released or reused too quickly before the image at the url loads.
精彩评论