简体   繁体   English

UIPageViewController中的navigationController pushViewController不起作用

[英]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.

相关问题 NavigationController pushViewController不起作用 - NavigationController pushViewController doesn't work 为什么self.navigationController pushViewController不起作用? - Why won't self.navigationController pushViewController work? 即使我有navigationController,pushViewController也无法正常工作 - pushViewController doesnt work even though i have a navigationController navigationController.pushViewController 似乎在 Xcode 11 中不起作用? - navigationController.pushViewController doesn't seem to work in Xcode 11? iOS NavigationController pushViewController不起作用 - iOS navigationController pushViewController not working 没有导航控制器的 pushViewController - pushViewController without navigationcontroller Swift - 来自 appDelegate 的 pushViewController,rootViewController.navigationController 为零 - Swift - pushViewController from appDelegate, rootViewController.navigationController is nil 嵌入到NavigationController swift4中时,从UIPageViewController更新ChildViewController - Update ChildViewController from UIPageViewController when embeded in NavigationController swift4 navigationController..pushViewController无法启动视图 - navigationController?.pushViewController fails to launch the view self.navigationController pushViewController 不工作 - self.navigationController pushViewController not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM