フレームのUICollectionViewがあります
[UIScreen mainScreen].bounds
およびこれらの属性:
_collectionView.pagingEnabled = YES;
_collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
セルには、コレクション ビューのサイズもあります。回転すると、コレクション ビューの contentOffset が新しい向きに収まりません。回転前と同じオフセットのままです。
これを修正するために、didRotate メソッドで contentOffset を手動で変更しました。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
_collectionView.contentOffset = CGPointMake(_newContentOffsetX, _collectionView.contentOffset.y);
}
これは機能しますが、ひどいようです。また、現在の IndexPath までスクロールしようとしましたが、同じ醜い動作をしています。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[_collectionView scrollToItemAtIndexPath:_currentIndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:NO];
}
デバイスを回転させるときに、コレクション ビューのコンテンツ オフセットを更新するクリーンな遷移と動作が必要です。