Как повернуть UICollectionView, похожий на приложение для фотографий, и сохранить текущий вид по центру?

У меня есть вид фотогалереи, который используетUICollectionView сUICollectionViewFlowLayout, в нем естьpagingEnabled и прокручивает горизонтально, показывая только один вид за раз.

Прекрасно работает, пока я не попробую повернуть его ...

Когда я поворачиваю устройство, вwillRotateToInterfaceOrientation:duration: Я обновляюcollectionView.contentOffset поэтому он остается на правильном элементе, и я изменяю размер currentCell, чтобы он анимировался в новые измерения.Проблема в анимации между двумя состояниями, анимация «предыдущей»из верхнего левого угла И бросает в глаза другие клетки. Что я делаю не так, что анимированный вид с экрана - это FUBAR?

Вот как это выглядит в действии:

http://www.smugmug.com/gallery/n-3F9kD/i-BwzRzRf/A (игнорируйте изменчивое видео, это вина Quicktime: p)

Вот мойwillAnimateRotationToInterfaceOrientation:duration:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];

// Update the flowLayout's size to the new orientation's size
UICollectionViewFlowLayout *flow = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
    flow.itemSize = CGSizeMake(self.collectionView.frame.size.width, self.collectionView.frame.size.height);
} else {
    flow.itemSize = CGSizeMake(self.collectionView.frame.size.width, self.collectionView.frame.size.height);
}
self.collectionView.collectionViewLayout = flow;
[self.collectionView.collectionViewLayout invalidateLayout];

// Get the currently visible cell
PreviewCellView *currentCell = (PreviewCellView*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:_currentIndex inSection:0]];

// Resize the currently index to the new flow's itemSize
CGRect frame = currentCell.frame;
frame.size = flow.itemSize;
currentCell.frame = frame;

// Keep the collection view centered by updating the content offset
CGPoint newContentOffset = CGPointMake(_currentIndex * frame.size.width, 0);
self.collectionView.contentOffset = newContentOffset;
}

Насколько мне известно, я не могу найти ни одного примера кода, который бы иллюстрировал, как сделать представление коллекции фотографий в стиле «фотогалерея», которое вращается изящно.

Ответы на вопрос(3)

Ваш ответ на вопрос