Ios 嵌入父控制器时-[UICollectionViewData validateLayoutInRect:]中的断言失败
情景:Ios 嵌入父控制器时-[UICollectionViewData validateLayoutInRect:]中的断言失败,ios,objective-c,uicollectionview,uicollectionviewlayout,Ios,Objective C,Uicollectionview,Uicollectionviewlayout,情景: 视图控制器ControllerA,其中包含集合视图 已在控制器a的viewdiload中为该集合视图提供了自定义布局:self.collectionView.collectionViewLayout=[[MyCustomFlowLayout alloc]init] 如果ControllerA加载到屏幕上,它工作正常,但是如果它加载到另一个控制器中,比如说ParentController,它会给出一个断言错误,如下所示: *-[UICollectionViewData validateLa
self.collectionView.collectionViewLayout=[[MyCustomFlowLayout alloc]init]代码>
在嵌入不同的控制器时,自定义布局存在一些问题。但我不知道是什么。有什么想法吗 我知道这个问题很老了,但我想我应该发布一个答案,因为我也遇到了这个问题。我在垂直滚动集合视图单元格中使用水平滚动集合视图 在视图控制器中:
- (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;
}];
}
在包含collectionView的PromoFeedCollectionCell中:
- (void)resizeCellView
{
[self setNeedsLayout];
[self.collectionView performBatchUpdates:nil completion:^(BOOL finished){
finished = YES;
}];
}