簡體   English   中英

如何從UIViewController過渡到UINavigationController

[英]How to transition to a UINavigationController from a UIViewController

我試圖通過segue從UIViewController過渡到UINavigationController (模態)。 我的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操作。 在調用performSegueWithIdentifier函數之后並且在segue轉換發生之前,將調用prepareForSegue

您需要為導航控制器定義一個根視圖關系,否則將無任何顯示。

導航控制器是容器視圖控制器,即,它將其他視圖控制器的內容嵌入其內部。

每個導航堆棧必須至少具有一個視圖控制器才能充當根目錄。

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/index.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM