Rotation Jumping Pages #80

jasonlagaac opened this Issue Apr 28, 2012 · 2 comments

3 participants


Hi :)

I am currently having issues with grid rotation of multiple paginated views. When I am at a specific page and I rotate the device, the grid jumps pages.

I have tested it out in these scenarios:

Landscape to Portrait: Jumps forward a page.
Portrait to Landscape: Jumps backward a page.

Here is some sample video:

Sorry for the bad video quality.

I hope this is clear enough :)




I am seeing this as well with paging mode. I have a full screen grid view which shows one cell at a time. Since size is different in landscpape and portrait the index is not maintained correctly.

The bug in layoutSubviews where the page index i calculated using a scroll offset (after rotation)

    // line 349
    if (self.pagingEnabled) 
        [self setContentOffset:[self rectForPoint:self.contentOffset inPaggingMode:YES].origin animated:YES];

I tried to keep the currentBounds size of the frame and apply the transformation to the contentOffset:

CGPoint currentContentOffset = CGPointMake(self.bounds.size.width * (self.contentOffset.x / currentBounds.size.width), 0.0);
[self setContentOffset:[self rectForPoint:currentContentOffset inPaggingMode:YES].origin animated:YES];
// keep the bounds to be able to compute the contentOffset corresponding to the current orientation
currentBounds = self.bounds;

It seems to work most of the time... sometimes not at the first rotation. If someone has a better fix, please share it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment