Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.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
Ios6 UICollectionView在旋转时重新加载单元格_Ios6_Reload_Uicollectionview_Cells - Fatal编程技术网

Ios6 UICollectionView在旋转时重新加载单元格

Ios6 UICollectionView在旋转时重新加载单元格,ios6,reload,uicollectionview,cells,Ios6,Reload,Uicollectionview,Cells,因此,我为UICollectionView创建了自己的自定义布局。当我从纵向模式旋转到横向模式时,一些单元格开始重新加载其内容。我以为布局只是改变了每个单元格的位置,而不是重新加载内容 仅当我在collection视图上调用reload Data时,才应重新加载内容 对可能发生的事情有什么想法吗 不确定您是否有此目标,但这里是: - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrien

因此,我为UICollectionView创建了自己的自定义布局。当我从纵向模式旋转到横向模式时,一些单元格开始重新加载其内容。我以为布局只是改变了每个单元格的位置,而不是重新加载内容

仅当我在collection视图上调用reload Data时,才应重新加载内容


对可能发生的事情有什么想法吗

不确定您是否有此目标,但这里是:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    [self.collectionView reloadData];
}

不确定您是否有此目标,但这里有:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    [self.collectionView reloadData];
}

在旋转时使用
invalidateLayout
而不是
reloadData
,或者在UICollectionViewLayout子类中覆盖
shouldInvalidateLayoutForBoundsChange:
并返回YES。

在旋转时使用
invalidateLayout
而不是
reloadData
,或者重写
应该为边界设置验证布局:
并在UICollectionViewLayout子类中返回YES。

只是猜测:由于
UICollectionView
UITableView
有很多共同点,因此表视图行为也适用于集合视图
UITableView
覆盖
layoutSubview
并在方向更改时调用
reloadData
。也许它只是没有被记录……只是一个猜测:由于
UICollectionView
UITableView
有很多共同点,我可以想象,表视图行为也适用于集合视图
UITableView
覆盖
layoutSubview
并在方向更改时调用
reloadData
。也许只是没有记录。。。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    myCollectionView.frame = self.view.bounds;
    [myCollectionView.collectionViewLayout invalidateLayout];
}