Each UITableViewCell
contains a UICollectionView
. Having trouble figuring out why some UICollectionViewCell
images are not showing up. I'm using SDWebImage
library to load images. The method - (void)sd_setImageWithURL:(NSURL *)url
calls [self sd_cancelCurrentImageLoad];
. I think cancelling the previous request is the problem, but read somewhere that will create a race condition. Problem doesnt happen for every UITableViewCell
, and if I tap on cell for details and go back, the images fill in. Perhaps I need to reload data somewhere. Any tips on how to solve this?
if you try to image fatch from server to try this.
#import "UIImageView+WebCache.h"
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NewProfileCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
[cell.img_user_image sd_setImageWithURL:[NSURL URLWithString:[mutDict valueForKey:@"UserImageURL"][indexPath.row]] placeholderImage:[UIImage imageNamed:@"No_IMAGE_PLACE"]];
return cell;
}
Try it:
- (void)prepareForReuse
{
[super prepareForReuse];
[self.imageView cancelCurrentImageLoad];
[self.imageView setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal]; // Placeholder image
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.