2015-04-06 175 views
0

我有兩個控制器,第一個(UITableViewController)和第二個(UIViewController),都有UINavigationBar。當我在第二個控制器中時,我正在使用UIBarButtonItem,我想在維護數據的同時返回第一個控制器。數據存儲並獲得轉換,但不會在第一個控制器中加載UINavigationBar。請幫幫我。沒有顯示導航欄

@IBAction func buttonDone(sender: UIBarButtonItem) { 
    if countElements(textView.text) > 0 { 
     saveText() 
     toBackFirst() 

    } 
} 

func toBackFirst() { 
    let firstViewController:FirstTableViewController = FirstTableViewController() 
    self.presentViewController(firstViewController, animated: true, completion: nil) 
} 

回答

1

而不是使用presentViewController。您需要使用推送將其推送到navigationStack。

試試這個:

func toBackFirst() { 
    let firstViewController:FirstTableViewController = FirstTableViewController() 
    self.navigationController?.pushViewController(firstViewController, animated: true) 
} 
+0

它的工作原理,但不顯示已添加到故事板的轉換按鈕。 – Alexsander

+0

https://www.dropbox.com/s/m7j8rgbel6x8yei/IMG_0591.jpg?dl=0 – Alexsander

+0

哦,你正在使用故事板。在這種情況下,您需要查看如何以編程方式執行segue。我從來沒有使用故事板,所以我不能幫你一個具體的代碼示例。但是,只要用編程的方式搜索「快速搜索」,就能找到你正在尋找的答案。 – MLyck