I have recently started using UICollectionView, and am a bit confused about the UICollectionViewFlowLayout. It would seem that the frames for each cell in the collection view ar
Workaround: subclass UICollectionViewFlowLayout
, override UICollectionViewLayout
's -layoutAttributesForElementsInRect:
and for every layout attributes make the frame integral:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
NSArray *allLayoutAttributes = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes *layoutAttributes in allLayoutAttributes) {
layoutAttributes.frame = CGRectIntegral(layoutAttributes.frame);
}
return allLayoutAttributes;
}
Note: iOS 7 UICollectionViewFlowLayout
has been fixed to always use integral frames for its cells' frames. I recommend keeping the fix for iOS 6.x but conditionally deprecate it for iOS 7 and newer.
Best, Raphael