ios - 如何从 UIViewController 过渡到 UINavigationController

标签 ios swift uinavigationcontroller

我正在尝试通过 segue 转换(模态)到 UINavigationController来自UIViewController . 我的UIViewControllerUINavigationController在界面生成器中。

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    self.performSegueWithIdentifier("showNavController", sender: self)
}

但是它一直给我一个警告: Warning: Attempt to present <UINavigationController: 0x14d5095e0> on <Test.ViewController: 0x14d60d9d0> whose view is not in the window hierarchy!

最佳答案

为什么要在 prepareForSegue 中调用 performSegueWithIdentifier
这就是导致错误的原因。您不必再次调用 performSegueWithIdentifier

performSegueWithIdentifier 用于执行 segue 操作。 prepareForSegue 在您调用 performSegueWithIdentifier 函数之后和 segue 转换发生之前被调用。

关于ios - 如何从 UIViewController 过渡到 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27906688/

相关文章:

ios - 将屏幕拆分为两个 View Controller SpriteKit + Swift

ios - Swift:无法播放基于数组的每个声音序列

ios - View 仅显示在 iphone 的状态栏中

ios - self.navigationController 分配为 RootViewController 后为空?

ios - 调用中参数 'sender' 缺少参数

ios - 如何在iOS中读取带有字符串值的EXCEL XLSX文件?

ios - graph.facebook.com - 传输安全 block

ios - 在 Info.plist iOS 中将 IP 范围添加到传输安全层

ios - 在启动时以编程方式为 5 个选项卡栏项目设置选项卡栏标题,其中 4 个嵌入在导航 Controller 中,1 个不是。 objective-c

ios - 在 UINavigationController 中的不同 'layers' 之间跳转