In my iOS app I have have a lots of view and image and labels are the subviews of the. view. My problem is while loading images from url or remote server only last image is loading from url . Other images are loaded with placeholders. Tried many ways but unable to solve it . My code and screenshot are provided below
catScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 10, self.view.frame.size.width,300)];
catScrollView.contentSize = CGSizeMake(([popularCategoryArray count] * 90)/1.8 + 10, catScrollView.frame.size.height);
[_parentScrollView addSubview:catScrollView];
catScrollView.backgroundColor=UIColorFromRGB(0xE8F7FE);
catScrollView.userInteractionEnabled=YES;
catScrollView.scrollEnabled=YES;
catScrollView.delegate=self;
for(int i =0;i<[popularCategoryArray count];i++)
{
Category* category=[popularCategoryArray objectAtIndex:i];
UIView *catView = [[UIView alloc] init];
if(i>=[popularCategoryArray count]/2+1)
{
catView.frame = CGRectMake(10 + y * 100, 4*10+90+10, 90, 120);
y++;
}
else
{
catView.frame = CGRectMake(10 + x * 100, 10, 90, 120);
x=i;
}
imageCat=[[UIImageView alloc]initWithFrame:CGRectMake(10, 0, 70, 90)];
imageCat.backgroundColor=[UIColor clearColor];
[imageCat sd_setImageWithURL:[NSURL URLWithString:category.ImageURL]
placeholderImage:[UIImage imageNamed:@"wish_list"]];
[catView addSubview:imageCat];
UILabel *labelCat=[[UILabel alloc]initWithFrame:CGRectMake(0, 95, catView.frame.size.width, 25)];
labelCat.backgroundColor=[UIColor clearColor];
labelCat.text=category.BngTitle;
labelCat.textAlignment=NSTextAlignmentCenter;
labelCat.font=[UIFont fontWithName:@"HelveticaNeue-Thin" size:12.0];
[catView addSubview:labelCat];
catView.backgroundColor=[UIColor clearColor];
[catScrollView addSubview:catView];
}
Screenshot