【问题标题】:How to jump to any ViewController in another UINavigationController如何跳转到另一个 UINavigationController 中的任何 ViewController
【发布时间】:2014-10-15 09:43:36
【问题描述】:

我有一个使用情节提要创建的项目。我有很多 ViewControllers,与 segues 连接。现在我想从 ViewController (下面的 VC) A 中获取,它嵌入在一个 navigationController 中(作为 RootVC),并由另一个 VC B (也由另一个 VC C 模态地呈现)呈现给任何其他 VC故事板中的 D(在这种情况下,主导航控制器 E 中的第一个)。 我经历了 NavigationController 层次结构被模态 segue “破坏”,并且因为我需要在 VC A 中使用 push segue 的函数,我需要使用第二个 NavigationController ......我已经尝试保存一个实例全局目标 VC D,然后跳转到那里

    self.navigationController.popToViewController(myDestinationVC_D, animated: true)

但后来我收到一个错误,因为解压了一个 nil-optional。

我希望你能帮助我。我认为给定的信息应该足够了,但是如果您需要更多信息,请发表评论。 (我希望我的英语不要太差;)) 谢谢!

【问题讨论】:

  • 您好,请问您可以显示更多代码吗?

标签: ios xcode uiviewcontroller uinavigationcontroller swift


【解决方案1】:

我打算用objective-c写,但我相信你可以转换成swift。

some *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"some identifier you add to a vc in the storyboard"];

然后按一下即可查看。

【讨论】:

    【解决方案2】:

    斯威夫特版本:

    navigationController!.pushViewController(storyboard!.instantiateViewControllerWithIdentifier("View Controller Identifier") as UIViewController, animated: true)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多