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