简体   繁体   English

UIPageViewControllerDelegate-iOS 5的willTransitionToViewControllers替代

[英]UIPageViewControllerDelegate - willTransitionToViewControllers replacement for iOS 5

I'm using 我正在使用

- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers

to track current visible page in a UIPageViewController . 跟踪UIPageViewController当前可见页面。 This method is available from iOS 6 but I need to achieve this also in iOS 5 , how could I do that? iOS 6提供了此方法,但我也需要在iOS 5中实现此方法,我该怎么做? I tried with 我尝试过

- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed

but previousViewControllers count is always one, so it's no help or probably I'm missing something previousViewControllers ViewControllers计数始终为1,因此它无济于事,或者我可能错过了一些东西

The UIPageViewController can show two UIViewController instances when it has its spine location at UIPageViewControllerSpineLocationMid ,otherwise it shows one. UIPageViewController位置位于UIPageViewControllerSpineLocationMid时,它可以显示两个UIViewController实例,否则显示一个。

To get a reference to the view controller currently going out of the view, you can have it via the previousViewControllers parameter in its delegate. 要获取当前退出视图的视图控制器的引用,可以通过其委托中的previousViewControllers参数获得它。 It will contain the references to the view controllers previously being shown on screen. 它将包含以前显示在屏幕上的视图控制器的引用。

For eg. 例如。 if you have MyContentViewController class which is being passed in your page view controller's datasource methods, you can get the reference to the view controller which is going out of screen in the delegate as: 如果您在页面视图控制器的数据源方法中传递了MyContentViewController类,则可以获取对视图控制器的引用,该引用在委托中不显示在屏幕上,如下所示:

MyContentViewController *myVC = (MyContentViewController*)[previousViewControllers objectAtIndex:0];

And to get the reference to current view controller, use viewControllers property of UIPageViewController . 并获得参照当前视图控制器,使用viewControllers财产UIPageViewController

MyContentViewController *myVC = (MyContentViewController*)[[self.pageViewController viewControllers] objectAtIndex:0];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM