来自UIPageViewController的navigationController pushViewController不工作
问题描述:
我是iOS开发新手。 我有一个导航控制器故事板和UIViewController
连接到它。来自UIPageViewController的navigationController pushViewController不工作
在UIViewController
自定义类,我添加三个UIViewController
下UIPageViewController
:
_one= [self.storyboard instantiateViewControllerWithIdentifier:@"View1"];
_two = [self.storyboard instantiateViewControllerWithIdentifier:@"View2"];
_three = [self.storyboard instantiateViewControllerWithIdentifier:@"View3"];
_page = [[CustomUIPageViewController alloc] initWithParentViewController:self];
_page.viewControllers = @[_one, _two, _three];
[self.view addSubview:_page.view];
...
我想通过调用显示从页面_TWO视图验证码:
ResultViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ResultBoard"];
[self.navigationController pushViewController:view animated:YES];
但它不工作,我也尝试:
[self.parentViewController.navigationController pushViewController:view animated:YES];
答
我可以解决我的PROBL他们现在。这不是一种“干净”的方式,但它的工作。 在_TWO控制器我补充一下:
@property (weak, nonatomic) UINavigationController *navigationCustomController;
然后初始化当我添加:
_two.navigationCustomController = self.navigationController;
从那以后,我只要致电:
ResultViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ResultBoard"];
[_navigationCustomController pushViewController:view animated:YES];
而且它的工作。
哪个视图显示? –
@ S.Jain这是一个UIViewController的故事板页面。 – DzungPV