2017-05-05 58 views
1

我有一個使用SWRevealViewController創建的滑出菜單。滑出菜單的每一行都連接到一個NavigationController。 我將兩個不同的TableViewController的兩行連接到顯示segue相同的ViewController。一個ViewController中的多個NavigationControllers

This is part of my Storyboard

當我從第一NavigationController導航視圖控制器正常工作和所點擊的單元的描述在導航條被設置。

class Details: UIViewController { 

var name:String = "" 

override func viewDidLoad() { 
    super.viewDidLoad() 
    self.navigationItem.title = name 

    print(name) 

} 

相反,當我從第二個NavigationController導航時,ViewController不起作用。導航欄未顯示,但打印了「名稱」參數。

任何人都可以幫我解決這個問題嗎?

+0

認沽條件didSelectRowAtIndexPath方法一樣(如果indexPth.row == 2)和編碼 –

+0

我想你不使用PUSH導航,烏爾目前使用的導航 –

+0

解決您的問題或靜止面臨同樣的問題? – Krunal

回答

0

試試這個,看看:

override func viewDidLoad() { 
    super.viewDidLoad() 

    print(name) 
    self.navigationItem.title = name 

    if let navController = self.navigationController { 
     navController.isNavigationBarHidden = false 
    } else { 
     print("There is no Navigation Controller. You may not be showing this controller using 'navigation push'") 
    } 


} 
0

你可以在你的代碼添加,並把指數無。和細胞的標題:

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) 
{ 

    switch (indexPath.row) 
    { 
    case 2: name = "yourFirstNavigationTitleName" 
     break 
    case 3: name = "yourSecondNavigationTitleName" 
     break 
    default: break 
    } 

} 
相關問題