Logging only once for UICollectionViewFlowLayout cache mismatched frame

hollylord 2015-08-17 10:12:33
小弟我用故事版上弄了一个UICollectionview,自定义flowlayout;
设定cell的size为(401,148)
当我在它的代理方法里面取出cell的时候(UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"picture" forIndexPath:indexPath];)
打印发现前4个cell的size为(50,50);后面显示的cell的size都正常。请问这是什么原因。

下面是xcode给我的提示:
Logging only once for UICollectionViewFlowLayout cache mismatched frame
UICollectionViewFlowLayout has cached frame mismatch for index path <NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0} - cached value: {{-72.498976843927437, 14.090629367551388}, {447.84976661094447, 189.53807857184424}}; expected value: {{0, 35}, {401, 148}}
This is likely occurring because the flow layout subclass myFlowLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them

求大神帮帮忙!!!!
...全文
584 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
7c 2016-03-31
  • 打赏
  • 举报
回复
自定义flowlayout需要在
- (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect{
    NSArray * original   = [super layoutAttributesForElementsInRect:rect];
    NSArray * array = [[NSArray alloc] initWithArray:original copyItems:YES];
    return array;
}
返回所有[super layoutAttributesForElementsInRect:rect]的拷贝
qq_32210617 2015-12-11
  • 打赏
  • 举报
回复
我也是这样的问题,没有解决 但没影响 = =

29,031

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧