场景:
视图控制器 ControllerA ,其中包含集合视图。
此集合视图已在控制器A的 viewDidLoad 中获得自定义布局:self.collectionView.collectionViewLayout = [[MyCustomFlowLayout alloc]init];
* 断言失败 - [UICollectionViewData validateLayoutInRect:],/ SourceCache / UIKit_Sim / UIKit-2935.137 / UICollectionViewData.m:357
我想张贴一张图片,但直到我有10个声望点才能发布。
嵌入不同控制器时自定义布局存在一些问题。但我无法弄清楚是什么。有任何想法吗 ?
答案 0 :(得分:0)
我知道这些问题已经过时了,但我想我会发布一个答案,因为我也遇到了这个问题。我在垂直滚动集合视图单元格中使用水平滚动集合视图。
在视图控制器中:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[self.collectionView performBatchUpdates:nil completion:^(BOOL finished)
{
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:kSaleSection];
PromoFeedCollectionCell *cell = (PromoFeedCollectionCell *) [self.collectionView cellForItemAtIndexPath:indexPath];
if (cell)
{
[cell resizeCellView];
}
finished = YES;
}];
}
在我的PromoFeedCollectionCell中包含collectionView:
- (void)resizeCellView
{
[self setNeedsLayout];
[self.collectionView performBatchUpdates:nil completion:^(BOOL finished){
finished = YES;
}];
}