在试图显示UICollectionView时,模拟器中会出现以下错误:
UIKit`-[_UIFlowLayoutSection updateEstimatedSizeForSection:]:
...
0x106d32858 <+582>: movq 0x416909(%rip), %rcx ; _UIFlowLayoutSection._validItemRange
0x106d3285f <+589>: xorl %edx, %edx
-> 0x106d32861 <+591>: divq 0x8(%rcx,%rbx)
Thread 1: EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)我已经正确地设置了估计的单元格大小,并且设置集合视图的高度大于单元格高度。所有的嵌入都被设置为0。但在坠机前,我仍然收到以下警告:
the behavior of the UICollectionViewFlowLayout is not defined because:
the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
Please check the values return by the delegate.
The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7fe65d28b7c0>, and it is attached to <UICollectionView: 0x7fe65c859000; frame = (5 63; 365 110); clipsToBounds = YES; opaque = NO; gestureRecognizers = <NSArray: 0x7fe65d28bea0>; animations = { opacity=<CABasicAnimation: 0x7fe65d702fd0>; bounds.origin=<CABasicAnimation: 0x7fe65d704610>; bounds.size=<CABasicAnimation: 0x7fe65d704630>; }; layer = <CALayer: 0x7fe65d03a0b0>; contentOffset: {0, 0}; contentSize: {1798, 110}> collection view layout: <UICollectionViewFlowLayout: 0x7fe65d28b7c0>.
Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.有什么想法吗?
发布于 2016-02-07 00:03:37
我通过将UIImageView大小设置为集合视图单元格中的固定大小来修正这个问题,而不是使用约束将图像视图扩展到单元格的大小。
这很奇怪,因为UICollectionView不应该将单元格缩放到大于dataSource中返回的大小。此外,当UIImageView = true时,clipsToBounds大小与单元格大小有什么关系?只要单元格本身有正确的大小,UICollectionView甚至不应该知道单元格包含什么视图。
https://stackoverflow.com/questions/35225045
复制相似问题