我UIPageViewController
在横向模式下调整大小时遇到问题。
这是我的情况:
我UIViewController
里面有一个scrollview
。我UIPageViewController
以scrollview
编程方式添加了一个,它正确显示了每个页面中的所有视图控制器。当我将设备方向更改为横向时,我正在正确更改的内容大小,scrollview
但PageViewController
最多只能显示其内容的一半。你能帮我这个忙吗?
谢谢,阿南德
您似乎未正确设置设备方向或试图在viewDidLoad
功能中进行设置。以下代码应将页面视图控制器的框架正确设置为当前方向。
- (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;
}
请注意,代码是从
viewWillLayoutSubviews
函数中调用的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句