Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 嵌入父控制器时-[UICollectionViewData validateLayoutInRect:]中的断言失败_Ios_Objective C_Uicollectionview_Uicollectionviewlayout - Fatal编程技术网

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

情景:

  • 视图控制器ControllerA,其中包含集合视图

  • 已在控制器a的viewdiload中为该集合视图提供了自定义布局:
    self.collectionView.collectionViewLayout=[[MyCustomFlowLayout alloc]init]

  • 如果ControllerA加载到屏幕上,它工作正常,但是如果它加载到另一个控制器中,比如说ParentController,它会给出一个断言错误,如下所示:
  • *-[UICollectionViewData validateLayoutInRect:]、/SourceCache/UIKit_Sim/UIKit-2935.137/UICollectionViewData.m:357中的断言失败

    我想发布一张图片,但在我获得10点声誉积分之前无法发布


    在嵌入不同的控制器时,自定义布局存在一些问题。但我不知道是什么。有什么想法吗

    我知道这个问题很老了,但我想我应该发布一个答案,因为我也遇到了这个问题。我在垂直滚动集合视图单元格中使用水平滚动集合视图

    在视图控制器中:

    - (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;
        }];
    }