UIScrollView is between pages after device rotation

I've got a UIScrollView with paging enabled, with 2 pages. I'm using auto layout. When I rotate from portraint to landscape, the content offset of the scroll view ends up between pages. Is that normal, or is there something else in my app screwing it up? Is there a simple way to change the behavior, so it sticks to a page on rotation?


thanks, Rob

Answered by Frameworks Engineer in 95881022

Yes. Your app needs to reset the content offset of the scroll view to be a multiple of the new page width whenever the scroll view's size changes (e.g. in response to device rotation). The PageControl sample shows an example of this (in Classes/iPhone/RootViewController.m).

Accepted Answer

Yes. Your app needs to reset the content offset of the scroll view to be a multiple of the new page width whenever the scroll view's size changes (e.g. in response to device rotation). The PageControl sample shows an example of this (in Classes/iPhone/RootViewController.m).

Great, thanks for the help!

The example is now updated for Swift.


In


func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)


super is called twice. Is this a mistake or on purpose?

UIScrollView is between pages after device rotation
 
 
Q