[英]navigationController pushViewController from UIPageViewController not work
I am new to iOS development. 我是iOS开发的新手。 I have story board with a Navigation Controller and
UIViewController
connect to it. 我有一个带有导航控制器的故事板,并且
UIViewController
连接到它。
In UIViewController
custom class I add three UIViewController
under UIPageViewController
: 在
UIViewController
自定义类中,我在UIPageViewController
下添加了三个UIViewController
:
_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];
...
I want to show a view from page _two by call this code: 我想通过调用此代码显示_two页面上的视图:
ResultViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ResultBoard"];
[self.navigationController pushViewController:view animated:YES];
But it not work, I also try: 但这不起作用,我也尝试:
[self.parentViewController.navigationController pushViewController:view animated:YES];
I can solve my problem now. 我现在可以解决我的问题。 It is not a "clean" way but it work.
这不是一种“干净”的方法,但它可以工作。 On the _two Controller I add:
在_two控制器上,我添加:
@property (weak, nonatomic) UINavigationController *navigationCustomController;
And then when init I add: 然后在初始化时添加:
_two.navigationCustomController = self.navigationController;
After that I just call: 之后,我只打电话给:
ResultViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ResultBoard"];
[_navigationCustomController pushViewController:view animated:YES];
And it work. 而且有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.