在使用UICollectionViewFlowLayout自定义Item时,打印报出以下警告:
2017-06-01 15:59:20.965 EasyFlowerFind[2247:746359] Logging only once for UICollectionViewFlowLayout cache mismatched frame2017-06-01 15:59:20.966 EasyFlowerFind[2247:746359] UICollectionViewFlowLayout has cached frame mismatch for index path{length = 2, path = 0 - 1} - cached value: {{139.96000000000001, 0}, {62.840000000000003, 24}}; expected value: {{190, 0}, {62.840000000000003, 24}}
2017-06-01 15:59:20.966 EasyFlowerFind[2247:746359] This is likely occurring because the flow layout subclass EFTagsCollectionLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them
查了很多资料,给出的解决办法都是在:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect;
这个方法里面要对NSArray的UICollectionViewLayoutAttributes进行copy操作。
NSArray * array =[super layoutAttributesForElementsInRect:rect];
改成:
NSArray * array = [[NSArray alloc]initWithArray:[super layoutAttributesForElementsInRect:rect] copyItems:YES];
试过这个方法后还是不行,希望有看到的能解决的给说下。
网友评论