我有 UIPageViewController
,我可以使用下面的委托(delegate)方法进入下一页和上一页。
- (UIViewController *)pageViewControllerUIPageViewController *)pageViewController viewControllerBeforeViewControllerUIViewController *)viewController
{
if ([viewController isKindOfClass:[PageController class]])
return nil;
if(_counter < 1) {
return nil;
}
self.view.backgroundColor = [UIColor lightGrayColor];
return [self.storyboard instantiateViewControllerWithIdentifier"memoTable"];
}
编辑:
- (UIViewController *)pageViewControllerUIPageViewController *)pageViewController viewControllerAfterViewControllerUIViewController *)viewController
{
//NSLog(@"Child controller count = %lu",(unsigned long)pageViewController.childViewControllers.count);
if ([viewController isKindOfClass:[PageController class]])
return nil;
if([viewController isKindOfClass:[TableViewController class]])
{
TableViewController *viewController1 = (TableViewController*) viewController;
if (viewController1.dataArr.count < 5) {
return nil;
}
}
return [self.storyboard instantiateViewControllerWithIdentifier"pageView"];
}
现在如果满足某些条件,我想转到下一页。喜欢最后一页viewController.isCheck == true。
我怎样才能做到这一点?
您可以将该条件添加到现有 if 之一,如果条件未得到验证,则返回 nil。比如:
- (UIViewController *)pageViewControllerUIPageViewController *)pageViewController viewControllerAfterViewControllerUIViewController *)viewController
{
if ([viewController isKindOfClass:[PageController class]] || ((YourViewControllerClass *)viewController).isCheck == false)
return nil;
return [self.storyboard instantiateViewControllerWithIdentifier"pageView"];
}
关于ios - UIPageViewController 有条件地转到下一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40213526/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |