GMGridView
GMGridView copied to clipboard
Rotation Jumping Pages
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:
http://www.youtube.com/watch?v=mjARkGULAr8
Sorry for the bad video quality.
I hope this is clear enough :)
Cheers,
Jason
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.