Reputation: 7712
In my application I have used custom tableviewcell for loading two images in one cell, my problem is when I am loading that images on my view first time, it show swaped images (1st image in 2nd image and 2nd in 1st) and then after fraction of seconds it loads proper images (1st in 1st and 2nd in 2nd image). I am using AsyncImageView Class for display image.
Every first time view load it shows wrong and then after correct every time.
In CellForRow
AsyncImageView *imageView = [[AsyncImageView alloc] initWithFrame:celllookAlik.btnFullImg.frame];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
imageView.tag = IMAGE_VIEW_TAG1;
[celllookAlik addSubview:imageView];
AsyncImageView *imageViewll = [[AsyncImageView alloc] initWithFrame:celllookAlik.lookAlikeImage.frame];
imageViewll.contentMode = UIViewContentModeScaleAspectFill;
imageViewll.clipsToBounds = YES;
imageViewll.tag = IMAGE_VIEW_TAG2;
[celllookAlik addSubview:imageViewll];
Display Image in cell using below code:
NSString * imageImage = @"";
imageImage = [[self.arrayResponseLookAlike objectAtIndex:indexPath.row] objectForKey:@"ImagePath"];
AsyncImageView *imageViewCelebrity = (AsyncImageView *)[celllookAlik viewWithTag:IMAGE_VIEW_TAG1];
//cancel loading previous image for cell
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageViewCelebrity];
//load the image
imageViewCelebrity.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",imageImage]];
NSString * imageImageceleb = @"";
imageImageceleb = [[self.arrayResponseLookAlike objectAtIndex:indexPath.row ] objectForKey:@"LookLikeImage"];
AsyncImageView *imageViewllTemp = (AsyncImageView *)[celllookAlik viewWithTag:IMAGE_VIEW_TAG2];
//cancel loading previous image for cell
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageViewllTemp];
//load the image
imageViewll.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",imageImageceleb]];
Upvotes: 4
Views: 327
Reputation: 146
I have suffered with this type of problem, i have used SDWebImage.frameword. This framework integration is very easy, and it will load the images properly.
For this first we need to create UIImageView in place of AsyncImageView.
Display Image in cell using below code:
[mMainImgView setImageWithURL:[NSURL URLWithString:loImgurl] placeholderImage:[UIImage imageNamed:@"placeholder"]];
for remaining details check with https://github.com/rs/SDWebImage
Upvotes: 2