簡體   English   中英

使用標簽欄控制器和導航控制器

[英]Using Tab Bar Controller and Navigation Controller

在此處輸入圖片說明

我想在顯示的視圖控制器之間進行導航。 我不想使用segues。

當我嘗試通過單擊按鈕將窗體FirstViewController導航到SecondViewController

 let next = self.storyboard?.instantiateViewControllerWithIdentifier("secondViewController") as! SecondViewController

 self.presentViewController(next, animated: true, completion: nil)

我得到:

警告:嘗試在視圖不在窗口層次結構中的FirstViewController上顯示SecondViewController!

有什么想法如何在兩者之間插入導航控制器嗎?

編輯:在圖上是TabBarController而不是TabViewController

我使用以下命令從名為“ A-Controller”的First Scene的控制器導航到First View Controller:

@IBAction func navigateToFirstViewController(sender: AnyObject) {
    let next = self.storyboard?.instantiateViewControllerWithIdentifier("firstViewController") as! FirstViewController
    self.presentViewController(next, animated: true, completion: nil)
}

該圖未顯示。

如果嘗試通過TabBarController呈現模式視圖,則:

let next = self.storyboard?.instantiateViewControllerWithIdentifier("secondViewController") as! UIViewController
self.tabBarController.presentViewController(next, animated: true, completion: nil)

警告:嘗試在視圖不在窗口層次結構中的FirstViewController上顯示SecondViewController!

事實證明,此錯誤表示我的“第一視圖”出現並准備就緒后,必須從“第一視圖”導航到“第二視圖”。

將導航線放在viewDidAppear()函數中可以解決此問題。

暫無
暫無

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

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