0

我有一個activityfeedVC。如果用戶單擊一個tableViewCell,則會顯示一個activityVC。在這個VC中,我有一個「返回」按鈕。點擊時,我想返回到前一個視圖控制器。我能夠實現這一點,但我無法顯示tabBarController。我使用完成處理程序,但有些錯誤。希望你能幫助。當按下按鈕時呈現新的ViewController時如何顯示tabBarController

import UIKit 

class activityVC: UIViewController { 

    @IBAction func backBtnWasPressed(_ sender: Any) { 

     // Navigates back 
     let feedVC = storyboard?.instantiateViewController(withIdentifier: "feedVC") 

     func completionHandler() { 
      // show the tabBarController - NOT WORKING 
      feedVC?.tabBarController?.tabBar.isHidden = false 
      print("tabBarController shown") 
     } 

     present(feedVC!, animated: false, completion: completionHandler) 



    } 



    override func viewDidLoad() { 
     super.viewDidLoad() 

     // Do any additional setup after loading the view. 
    } 



} 

我想我應該用它代替我的客戶導航UINavigationBar的......也許這是比較容易,儘管我沒有需要這個功能很多意見...

+0

你調試,如果任何這些都是零,當你設置的值'feedVC?.tabBarController?.tabBar.isHidden = FALSE' – carbonr

+0

另外,在你的故事板'「feedVC」'的tabBarController或活動視圖控制器。如果故事板中可用,則需要鏈接到TabBarController。另一種方法是隻關閉當前的視圖控制器,而不是加載其他視圖控制器的輕擊按鈕,如果它的模態呈現 – carbonr

+0

它沒有模態地呈現,所以不起作用。 tabBarController是在類CustomTabBarController中以編程方式創建的。你是說,而不是呈現UIViewController我應該呈現CustomTabBarController? –

回答

0

你推activityVC到視圖控制器堆棧上?如果是這樣,當用戶點擊後退按鈕時,您可以簡單地彈出activityVC。

class activityVC: UIViewController { 

    @IBAction func backBtnWasPressed(_ sender: Any) { 
     self.navigationController?.popViewController(animated: false) 
    } 
} 
相關問題