我试图设置iOS 8自动调整大小细胞UICollectionViewController
:
我创建使用故事板基本设计,并设计一个UICollectionViewCell那里与约束到的边界标签细胞。然后,我将该单元格的标签链接到单元的类,以便能够以编程方式访问它。
没有指定estimatedItemSize
,一切工作正常(当然除了自动调整大小)。UICollectionView细胞自动尺寸与自动版式的iOS 8
当我指定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
,或者,如果我已经有在故事板中设置的指定项目大小,所以它与预计大小存在冲突。
是的它应该工作,但要注意,对于iPhone 6和6+你的标签不会覆盖所有的屏幕宽度... – jerrygdm
我已经做了一个插座,并在运行时改变约束的值到手机的屏幕宽度。 –
我有150宽度的单元格,但它不能调整为iphone 6和6 plus。你可以在这里找到它http://stackoverflow.com/questions/27981200/how-to-resize-uicollectionviewcell-in-iphone-6-and-6-plus-using-autolayout – Rugmangathan