【发布时间】:2014-05-11 07:24:32
【问题描述】:
在苹果 PhotoScroller 示例中,UIPageViewController 中显示了 3 个可缩放图像。您可以缩放这些图像并在它们之间进行页面缩放即使它们仍处于缩放状态。我的应用程序使用来自 PhotoScroller 的代码,唯一的区别是我的 UIPageViewController 是我的应用程序中另一个 UIViewController 的子视图控制器 - 即分页功能包含在视图层次结构中。在 Apple 的版本中,UIPageViewController 是根视图控制器(实际上由情节提要设置)。在我的代码中,除非我将内容返回到未缩放的比例,否则我不会获得分页行为。对于我的应用程序,我不想强迫用户这样做。我需要做些什么才能让它按我想要的方式工作?
更新 我已经确定手动将页面视图控制器设置为根视图控制器会导致苹果示例代码表现出不需要的行为。即在应用委托中创建页面视图控制器为
// assign the first page to the pageViewController (our rootViewController)
UIPageViewController *pageViewController = [[UIPageViewController alloc] init];
pageViewController.dataSource = self;
[pageViewController setViewControllers:@[pageZero]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:NULL];
self.window.rootViewController = pageViewController;
使缩放的图像仅在边缘反弹,而不是缩放到下一张图像。原代码为:
// assign the first page to the pageViewController (our rootViewController)
UIPageViewController *pageViewController = (UIPageViewController *)self.window.rootViewController;
pageViewController.dataSource = self;
[pageViewController setViewControllers:@[pageZero]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:NULL];
为什么这会破坏图像缩放时的滚动行为?
已解决
UIPageViewController 必须正确启动,因为
_pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
我只是打电话给alloc] init]。
【问题讨论】:
-
您是否可以添加一些代码或者可以将示例项目添加到 Github?谢谢。
-
让我看看我能做什么。
标签: ios uiscrollview uipageviewcontroller