Ios CollectionView大小在数据重新加载之前以popover segue显示时是错误的

Ios CollectionView大小在数据重新加载之前以popover segue显示时是错误的,ios,ipad,uicollectionview,uistoryboard,uipopovercontroller,Ios,Ipad,Uicollectionview,Uistoryboard,Uipopovercontroller,我在我的故事板上设置了一个segue作为Popover。destinationViewController是嵌入在NavigationController中的UICollectionViewController。当Popover视图加载时,my collectionView报告它的大小基本上是iPad窗口的全尺寸。但是,一旦我调用[self.collectionView reloadData],collectionView就会正确地将其大小视为PopOverview控制器的大小。下面是我用来调整

我在我的故事板上设置了一个segue作为Popover。destinationViewController是嵌入在NavigationController中的UICollectionViewController。当Popover视图加载时,my collectionView报告它的大小基本上是iPad窗口的全尺寸。但是,一旦我调用[self.collectionView reloadData],collectionView就会正确地将其大小视为PopOverview控制器的大小。下面是我用来调整collectionViewCell大小的方法,它基于collectionView的大小

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGSize collectionViewBounds = collectionView.bounds.size; //768x1004 when the Popover is first loaded
                                                             //400x644 after reloadData is called
    int navigationHeight = self.navigationController.navigationBar.bounds.size.height;
    int toolbarHeight = self.navigationController.toolbar.bounds.size.height;
    int statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;

    int cellHeight = collectionViewBounds.height - (navigationHeight + statusBarHeight + toolbarHeight);
    int cellWidth = collectionViewBounds.width;
    return CGSizeMake(cellWidth, cellHeight);
} 
我尝试手动将CGSize collectionViewBounds设置为我设置popoverView的大小,但在我重新加载数据之前,我的数据没有加载到collectionViewCell,并且此函数也停止工作:

- (void) snapToCellAtIndex:(NSIndexPath *)index withAnimation:(BOOL) animated
{
    [self.collectionView scrollToItemAtIndexPath:index atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:animated];
}
collectionView没有捕捉到索引,而是在两个单元格之间滚动,没有加载数据。这很好,因为我不想硬编码任何维度,所以我现在主要关注的是使初始负载大小正确

感谢您提供的任何帮助