iOS Developer

自定义UICollectionViewFlowLayout报的警

2016-09-02  本文已影响277人  fenglin

Logging only once for UICollectionViewFlowLayout cache mismatched frame**

UICollectionViewFlowLayout has cached frame mismatch for index path <NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1} - cached value: {{271.25, 41.25}, {117.5, 117.5}}; expected value: {{250, 20}, {160, 160}}**

CollectionView[50664:5115717] This is likely occurring because the flow layout subclass PhotoFlowLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them**

OC解决办法:

NSArray *attrs   =  [super layoutAttributesForElementsInRect:self.collectionView.bounds];

swift解决办法:

  let attributes = super.layoutAttributesForElementsInRect(self.collectionView!.bounds)
  var attributesCopy = [UICollectionViewLayoutAttributes]()
  for itemAttributes in attributes! {
        let itemAttributesCopy = itemAttributes.copy() as! UICollectionViewLayoutAttributes
        // manipulate itemAttributesCopy
        attributesCopy.append(itemAttributesCopy)
   }
查找的文章:

http://stackoverflow.com/questions/32720358/xcode-7-copy-layoutattributes
http://blog.csdn.net/mengxiangyue/article/details/50753839

上一篇 下一篇

猜你喜欢

热点阅读