In UIcollectionviewcell data is not loading in cell initially but cell's layout is loaded. When scrolled to the last cell and scrolled back it appears properly filled with data without any problem. I am getting the data from a json array. After getting json array i am reloading the collection view. I am using prototype cell in storyboard with autolayout. i have tried reloading using a button action but in that case only the visible cell is getting updated I am using flowlayout and horizontal scrolling this is my code for cellforitem
- (UICollectionViewCell *)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(NSIndexPath*)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ColCell" forIndexPath:indexPath];
UIImageView *img1=(UIImageView *)[cell viewWithTag:13];
img1.image = [UIImage imageNamed:@"profile_pic.png"];
if (![[[tableArray objectAtIndex:indexPath.row] valueForKey:@"img_extension"]isEqual:[NSNull null]] ) {
[img1 sd_setImageWithURL:[NSURL URLWithString:[[tableArray objectAtIndex:indexPath.row]valueForKey:@"img_extension"]] placeholderImage:nil completed:^(UIImage *image12, NSError *error, SDImageCacheType cachetype, NSURL *imageurl){
if(error)
img1 .image = nil;
else
img1 .image = image12;
CGPoint saveCenter1 = img1.center;
CGRect newFrame1 = CGRectMake(img1.frame.origin.x, img1.frame.origin.y,50, 50);
img1.frame = newFrame1;
img1.layer.cornerRadius = 50 / 2.0;
img1.center = saveCenter1;
img1.clipsToBounds = YES;
}];
}
UILabel *lbl1=(UILabel *)[cell viewWithTag:1];
UILabel *lbl2=(UILabel *)[cell viewWithTag:2];
UILabel *lbl3=(UILabel *)[cell viewWithTag:3];
UILabel *lbl4=(UILabel *)[cell viewWithTag:4];
UILabel *lbl5=(UILabel *)[cell viewWithTag:5];
UILabel *lbl6=(UILabel *)[cell viewWithTag:6];
UILabel *lbl11=(UILabel *)[cell viewWithTag:11];
UILabel *lbl12=(UILabel *)[cell viewWithTag:12];
UITextView *txtvw = (UITextView *)[cell viewWithTag:7];
lbl1.text=[[tableArray objectAtIndex:indexPath.row]valueForKey:@"strong_hand"];
lbl2.text=[[tableArray objectAtIndex:indexPath.row]valueForKey:@"athleticism"];
lbl3.text=[[tableArray objectAtIndex:indexPath.row]valueForKey:@"stick_skills"];
lbl4.text=[[tableArray objectAtIndex:indexPath.row]valueForKey:@"dodging"];
lbl5.text=[[tableArray objectAtIndex:indexPath.row]valueForKey:@"shooting"];
lbl6.text=[[tableArray objectAtIndex:indexPath.row]valueForKey:@"lacrosse"];
lbl11.text=[[tableArray objectAtIndex:indexPath.row]valueForKey:@"instructor_name"];
lbl12.text=@"INSTRUCTER";
txtvw.text = [[tableArray objectAtIndex:indexPath.row]valueForKey:@"comment"];
[cell layoutSubviews];
return cell;
}