0

我有我的故事板是這樣的:嵌套導航控制器和TabBar控制器

TabBarViewController 
|-NavigationViewController 
    |-TableViewController 

這有助於我必須在TableViewController同時導航欄和標籤欄。

現在我想添加一個SecondViewController來顯示在表中選擇的項目的細節。所以我這樣做:

TabBarViewController 
|-NavigationViewController 
    |-TableViewController 
    |-SecondViewController 

但SecondViewController不顯示導航欄。所以,我想這一點:

TabBarViewController 
|-NavigationViewController 
    |-TableViewController 
    |-NavigationViewController 
     |-SecondViewController 

但仍處於SecondViewContrller沒有導航欄。 我錯過了什麼?

+0

您只需要一個NavigationViewController。你在使用segues嗎?如果是這樣,是否有一個連接TableViewController到SecondTableViewController的segue? – Jordan

+0

是的,當我不使用第二個導航控制器時,我有一個從「TableViewController」到「SecondViewController」的「顯示」segue。 – Kashif

回答

1

我不完全確定你爲什麼需要像這樣嵌套的導航控制器?

請參閱下面的我認爲是您想要的故事板專用解決方案,或者您可以創建自定義委託來處理視圖堆棧和導航樹。

我在這裏假設你的'SecondViewController'是各種細節視圖?所以,像這樣:

TabBarViewController 
|-NavigationViewController 
    |-TableViewController (NavigationViewControllerDelegate) 
    |-DetailViewController (SecondViewController) 

這裏是故事板解決方案(無碼):

  1. 添加NavigationController到故事板
  2. 將其嵌入到標籤欄控制器(從菜單)
  3. 向Storyabord添加TableViewController
  4. 向表格中的單元格添加按鈕
  5. 添加標準d ViewController到故事板
  6. 的實現代碼如下單元的按鈕連接到新的視圖控制器
  7. 添加另一個標準ViewController到故事板,並給它一個標籤欄項目
  8. 鏈接標籤欄控制器添加到該視圖控制器

然後你最終的東西是這樣的:

+0

你說得對。它確實有效。原來,我在'SecondViewController'上有一個'navigationbar',但它的背景和後面的箭頭顏色都是白色的,因此它是不可見的。我在SecondViewController中改變了視圖的背景顏色,現在我很好! – Kashif