【发布时间】:2015-02-26 18:59:26
【问题描述】:
我正在尝试在UICollectionViewController 中设置 iOS 8 自动调整单元格大小:
我使用 StoryBoards 创建了一个基本设计,并在那里设计了一个 UICollectionViewCell,其标签限制在单元格的边界内。然后,我将该单元格的标签链接到一个单元格的类,以便能够以编程方式访问它。
如果不指定estimatedItemSize,一切正常(当然,自动调整大小除外)。
当我这样指定estimatedItemSize 时:
- (void)viewDidLoad {
[super viewDidLoad];
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionViewLayout;
layout.estimatedItemSize = CGSizeMake(100.0f, 30.0f);
}
应用程序崩溃并显示以下错误消息:
the behavior of the UICollectionViewFlowLayout is not defined because:
the item width must be less than the width of the UICollectionView minus the section insets left and right values.
Please check the values return by the delegate.
我认为,我将estimatedItemSize 设置在错误的位置,或者,如果我已经在情节提要中设置了指定的项目大小,那么它与估计的大小有某种冲突。
【问题讨论】:
标签: ios objective-c uicollectionview autolayout autosize