【问题标题】:navigationController pushViewController from UIPageViewController not work来自 UIPageViewController 的 navigationController pushViewController 不起作用
【发布时间】:2015-11-05 12:12:50
【问题描述】:

我是 iOS 开发的新手。 我有带有导航控制器的故事板,UIViewController 连接到它。

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];
...

我想通过调用以下代码从第 _two 页显示视图:

ResultViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ResultBoard"];
        [self.navigationController pushViewController:view animated:YES];

但是不行,我也试试:

[self.parentViewController.navigationController pushViewController:view animated:YES];

【问题讨论】:

  • 显示的是哪个视图?
  • @S.Jain 这是一个带有 UIViewController 的故事板页面。

标签: ios objective-c uiviewcontroller uinavigationcontroller uipageviewcontroller


【解决方案1】:

我现在可以解决我的问题了。这不是一种“干净”的方式,但它有效。 在我添加的 _two 控制器上:

@property (weak, nonatomic) UINavigationController *navigationCustomController;

然后在初始化时添加:

_two.navigationCustomController = self.navigationController;

然后我就打电话:

ResultViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ResultBoard"];
[_navigationCustomController pushViewController:view animated:YES];

而且它有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多