使用UICollectionViewFlowLayout自定义时报错

在使用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];

试过这个方法后还是不行,希望有看到的能解决的给说下。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容