美文网首页iOS Developer
自定义UICollectionViewFlowLayout报的警

自定义UICollectionViewFlowLayout报的警

作者: fenglin | 来源:发表于2016-09-02 14:28 被阅读277次

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

相关文章

网友评论

    本文标题:自定义UICollectionViewFlowLayout报的警

    本文链接:https://www.haomeiwen.com/subject/wkohettx.html