4

With XCode 6 and iOS 8 I encountered the problem that UICollectionViewCells does not autolayout / autoresize the subviews at first appearance. Once they have been shown and the cell is reused everything is fine.

Dominic Sander
  • 2,684
  • 1
  • 15
  • 29

2 Answers2

3

I put

[cell layoutIfNeeded];

after the dequeueReusableCellWithReuseIdentifier-Statement and everything was fine again.

Dominic Sander
  • 2,684
  • 1
  • 15
  • 29
1

I had the same issue. I tried to put [cell layoutIfNeeded];, but when I refresh the tableview, not all the cells are refreshed. With the code [cell layoutSubviews]; just before returning the cell, all cells are updated every time. Here is the complete piece of code

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
...
[cell layoutSubviews];
return cell;
}
barrast
  • 1,751
  • 1
  • 16
  • 27