Warning: UICollectionViewFlowLayout has cached frame mismatch for index path 'abc'

前端 未结 7 1235
心在旅途
心在旅途 2020-12-01 12:19

This is the code causing the warning:

private override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes         


        
相关标签:
7条回答
  • 2020-12-01 12:48

    In addition to the great answer above.

    I know the example code is written in swift, but I thought that it can be helpful to have the Objective-C version.

    For Objective-C, this won't work, because the copy function does only a shallow copy. You will have to do this:

    NSArray * original   = [super layoutAttributesForElementsInRect:rect];
    NSArray * attributes = [[NSArray alloc] initWithArray:original copyItems:YES];
    

    I have added a temp variable for readability.

    0 讨论(0)
提交回复
热议问题