With XCode 6 and iOS 8 I encountered the problem that UICollectionViewCell
s does not autolayout / autoresize the subviews at first appearance. Once they have been shown and the cell is reused everything is fine.
Asked
Active
Viewed 506 times
4
![](../../users/profiles/1058259.webp)
Dominic Sander
- 2,684
- 1
- 15
- 29
2 Answers
3
I put
[cell layoutIfNeeded];
after the dequeueReusableCellWithReuseIdentifier
-Statement and everything was fine again.
![](../../users/profiles/1058259.webp)
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;
}
![](../../users/profiles/1881895.webp)
barrast
- 1,751
- 1
- 16
- 27