UIPageViewController 有奇怪的大小 [英] UIPageViewController has strange size
问题描述
我在我的应用中使用了 UIPageViewController
.它工作得很好,但是当我翻页时,下一页似乎在比屏幕大的框架中初始化: 翻页时,只有下一个 viewController
的视图的一部分适合屏幕.
I am using a UIPageViewController
in my app.
It works quite well, but when I turn pages, the next page seems to get initialized in a frame that is bigger than the screen: While turning the page, only a part of the view of the next viewController
fits on the screen.
我正在viewDidLoad
中初始化UIPageViewController
并开始记录PageVC
的帧、它的子视图和parentVC代码>.每一帧似乎都没问题,只有我登录
viewControllerAfterViewController
的 UIPageViewController'
的帧的宽度几乎是屏幕实际大小的两倍.
I am initializing the UIPageViewController
in viewDidLoad
and started to log the frames of the PageVC
, its subviews and the parentVC
. Every frame seems to be okay, only the UIPageViewController'
s frame, which I log in viewControllerAfterViewController
has a width that is nearly the double of the screen's actual size.
推荐答案
我终于通过在初始化 PageVC 时将正确的框架设置为 UIPageViewController
的视图解决了这个问题:
I finally solved this issue by setting the right frame to the UIPageViewController
's view when initializing the PageVC:
pageViewController.view.frame = self.view.frame;
其中 pageViewController
是我初始化的 UIPageViewController
,self 是 pageVC 的父 VC.
Where pageViewController
is the UIPageViewController
I initialize,
and self is the parent VC of the pageVC.
希望这对有类似问题的人有所帮助.
Hope this helps anyone with similar problems.
这篇关于UIPageViewController 有奇怪的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!