Reputation: 329
I am having an issue with resizing UIPageViewController
in landscape mode.
Here is my scenario:
I have a UIViewController
which has a scrollview
in it.
I added a UIPageViewController
to the scrollview
programmatically and it is displaying all my view controllers in each page correctly.
When i change the device orientation to landscape i am correctly changing the content size of the scrollview
but the PageViewController
is displaying only up to half of its contents. Can you please help me with this one.
Thanks, Anand.
Upvotes: 2
Views: 1728
Reputation: 10615
It looks like you are either not getting the correct orientation of your device or trying to set it in the viewDidLoad
function. The following code should correctly set your page view controller's frame to current orientation.
- (void)viewWillLayoutSubviews {
CGRect screenFrame = [[UIScreen mainScreen] applicationFrame];
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
screenFrame = CGRectMake(0, 0, screenFrame.size.height, screenFrame.size.width);
}
//Please don't forget to replace _myPageViewController with your variable
_myPageViewController.frame = screenFrame;
}
Please note that code is getting called from
viewWillLayoutSubviews
function.
Upvotes: 3