【问题标题】:Adding ViewController to existing UINavigation stack将 ViewController 添加到现有 UINavigation 堆栈
【发布时间】:2014-02-11 07:09:19
【问题描述】:

如何在不使用initWithRootViewController的情况下在UINavigationController之上呈现模态ViewController,只需将其添加到现有的navigationcontroller堆栈中?

我的代码是:

TableViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"TableView"];
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navi animated:NO completion:nil];

编辑:我真正想做的是:“vc1 push vc2 modal vc3”,而不是使用“poptoroot ...to vc1”。但是 initWithRootViewController (vc3) 正在破坏它。

【问题讨论】:

  • 当前模式和添加到现有的导航控制器是互斥的。也许您正在寻找[self.navigationController pushViewController: controller animated:YES];?!
  • 我不想使用推送。代码在 is 完美运行。我真正想做的是:“vc1 push vc2 modal vc3”,而不是使用“poptoroot ... to vc1”。但是 initWithRootViewController (vc3) 正在破坏它。
  • 尝试展示你的控制器而不是导航

标签: xcode uinavigationcontroller


【解决方案1】:

如果你想改变navigationController的堆栈。使用:

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated NS_AVAILABLE_IOS(3_0); // If animated is YES, then simulate a push or pop depending on whether the new top view controller was previously in the stack.

会有帮助的。

【讨论】:

    猜你喜欢
    • 2017-12-17
    • 1970-01-01
    • 2012-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 1970-01-01
    • 2020-06-26
    相关资源
    最近更新 更多