我正在尝试使用页面视图控制器制作一些教程页面,我希望它在用户滑动教程的最后一页后自动跳转到另一个视图控制器。我已经实现了viewControllerAfterViewController
方法,如下所示:
if (index==self.contentPageRestorationIDs.count-1) {
[self performSegueWithIdentifier:@"toHelp" sender:self];
return nil;
}
return [self viewControllerAtIndex:index+1];
问题是,当涉及到最后一页时,它会立即执行segue。但我希望它在用户滑动最后一页后执行segue。我有什么方法可以做到吗?
答案 0 :(得分:0)
试试这个
__weak UIPageViewController* pvcw = pvc;
[pvc setViewControllers:@[page]
direction:UIPageViewControllerNavigationDirectionForward
animated:YES completion:^(BOOL finished) {
UIPageViewController* pvcs = pvcw;
if (!pvcs) return;
dispatch_async(dispatch_get_main_queue(), ^{
[pvcs setViewControllers:@[page]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO completion:nil];
});
}];
希望它有所帮助。
答案 1 :(得分:0)
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[yourViewController class]]) {
[self.navigationController popToViewController:controller
animated:YES];
}
else {
NSLog(@"Not Found");
}
}