Warning (Logging only once for UICollectionViewFlowLayout cache mismatched frame)
Console Output [ios 9 xcode 7]
2015-09-19 13:19:42.121 Wish'List[1710:60831] Logging only once for UICollectionViewFlowLayout cache mismatched frame 2015-09-19 13:19:42.122 Wish'List[1710:60831] UICollectionViewFlowLayout has cached frame mismatch for index path <NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0} - cached value: {{33.284175409625227, 84.198445826909605}, {307.14784245047292, 502.39185839645393}}; expected value: {{35, 83.5}, {305, 500.25}} 2015-09-19 13:19:42.123 Wish'List[1710:60831] This is likely occurring because the flow layout subclass RGCardViewLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them
how to fix this warning ?
In the layoutAttributesForElementsInRect method you have to working on a copy of UICollectionViewLayoutAttributes
This is my warning fix:
override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let attributes = super.layoutAttributesForElementsInRect(rect)
let cellIndices = self.collectionView!.indexPathsForVisibleItems()
if cellIndices.count == 0 {
return attributes
} else if (cellIndices.count == 1) {
mainIndexPath = cellIndices.first!
movingInIndexPath = nil
} else if (cellIndices.count > 1) {
let firstIndexPath = cellIndices.first
if (firstIndexPath == mainIndexPath) {
movingInIndexPath = cellIndices[1];
} else {
movingInIndexPath = cellIndices.first!
mainIndexPath = cellIndices[1]
}
}
difference = self.collectionView!.contentOffset.x - previousOffset;
previousOffset = self.collectionView!.contentOffset.x;
var attributesCopy = [UICollectionViewLayoutAttributes]()
for itemAttributes in attributes! {
let itemAttributesCopy = itemAttributes.copy() as! UICollectionViewLayoutAttributes
self.applyTransformToLayoutAttributes(itemAttributesCopy)
attributesCopy.append(itemAttributesCopy)
}
return attributesCopy
}