Note that there are some explanatory texts on larger screens.

plurals
  1. POCollectionView orientation issues
    text
    copied!<p>I currently have a collection view with a grid of images on it, when selecting an image this segues to another collection view with a full screen image on it.</p> <p>To do this I am using:</p> <pre><code> - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"collectionView"]) { QuartzDetailViewController *destViewController = (QuartzDetailViewController *)segue.destinationViewController; NSIndexPath *indexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0]; destViewController.startingIndexPath = indexPath; [destViewController.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; [self.collectionView deselectItemAtIndexPath:indexPath animated:NO]; } } </code></pre> <p>and then in my detail view:</p> <pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (_startingIndexPath) { NSInteger currentIndex = floor((scrollView.contentOffset.x - scrollView.bounds.size.width / 2) / scrollView.bounds.size.width) + 1; if (currentIndex &lt; [self.quartzImages count]) { self.title = self.quartzImages[currentIndex][@"name"]; } } } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout; layout.itemSize = self.view.bounds.size; [self.collectionView scrollToItemAtIndexPath:self.startingIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; } </code></pre> <p>when I rotate to landscape the image disappears and the title at the top changes, if I go back to the grid and then select a cell again it will segue again to the detail view but the title is for a different cell and the image shows half and half between two different images.</p> <p>I am getting the following message as well on the log when I rotate the device:</p> <pre><code>2013-06-04 17:39:53.869 PhotoApp[6866:907] the behavior of the UICollectionViewFlowLayout is not defined because: 2013-06-04 17:39:53.877 PhotoApp[6866:907] the item height must be less that the height of the UICollectionView minus the section insets top and bottom values. </code></pre> <p>How can I correct this so it will support orientation.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload