还在想这个,如果你强制 UIPageViewController 以横向和纵向显示 2 个页面,并将其放在 UIScrollerView 中。当您处于横向时,它会显示 2 页、缩放并按预期工作。如果你是纵向的,你可以让 UIPageViewController frame.width 是单页的 double,并且 UIScrollerView contentSize 和 UIPageViewController 一样宽,但是 UIScrollerView 框架宽度和一个页面一样宽。这样做你只显示一个页面并且可以滚动到第二个页面。我已经测试过并且在横向上工作正常,但在纵向上有一些问题,滑动更改页面不能从内部工作,但这从外部工作(这就是为什么我设置 _zoomer.frame = CGRectMake(10,10,widht ,height), 在 UIPageViewController 周围有一个 10 点的框架以从那里滑动),
我在屏幕旋转中使用的代码,仅适用于 iPad。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CGRect pageViewRect;
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
pageViewRect = CGRectMake(0,0,1496,984);
_zoomer.contentSize=CGSizeMake(1496, 984);
_zoomer.frame = CGRectMake(10,10,748,984);
self.pageViewController.view.frame = pageViewRect;
} else {
pageViewRect = CGRectMake(0,0,1004,728);
_zoomer.frame = CGRectMake(10,10,1004,728);
_zoomer.contentSize=CGSizeMake(1004, 728);
self.pageViewController.view.frame = pageViewRect;
}
}
_zoomer 是 UIScrollerView