在刷过最后一个视图控制器后,如何解除/弹出UIPageViewController?
基本上想要用图像制作一个教程样式的分页视图,并在用户从最后一页滑到“下一页”后解散.
基本上想要用图像制作一个教程样式的分页视图,并在用户从最后一页滑到“下一页”后解散.
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { NSUInteger index = [(EmailTutorialViewController *)viewController index]; index++; if (index == 5) { [self.navigationController popViewControllerAnimated:YES]; // this doesn't do anything return nil; } return [self viewControllerAtIndex:index]; }
解决方法
这是我用过的简单解决方案:
在
– (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController;
为索引返回空控制器== 5并添加此UIPageViewControllerDelegate方法:
- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers { EmailTutorialViewController *viewController = [pendingViewControllers objectAtIndex:0]; if ([viewController index] == 5) { [self.navigationController popViewControllerAnimated:YES]; } }