我在整個S.O中搜索過並發現了類似的文章,但沒有一個解決方案適用於我。下面是我的看法層次的截圖 從應用程序委託使用tabbar呈現當前視圖Controller-> Nav controller - > View Hierarchy - iOS Swift
一個代碼的許多片斷我已經試過如下:
var storyBoard = UIStoryboard()
if UIDevice.current.userInterfaceIdiom == .pad {
storyBoard = UIStoryboard(name: "iPad", bundle: nil)
} else {
storyBoard = UIStoryboard(name: "Main", bundle: nil)
}
let tabVc = self.window?.rootViewController as! UITabBarController
let mynVC = storyBoard.instantiateViewController(withIdentifier: "nav") as! UINavigationController
let calcVc = storyBoard.instantiateViewController(withIdentifier: "destVc")
tabVc.present(mynVC, animated: true, completion: {() -> Void in
// Segue , do stuff
})
上面的代碼呈現一個導航欄正確的標籤,但有沒有書面禮物。
我想有一個強制觸摸按鈕,呈現與導航欄和標籤欄目前的標籤,有誰知道如何做到這一點?
爲什麼是顯示導航控制器的標籤欄視圖控制器?您需要將導航控制器設置爲標籤欄視圖控制器中的當前控制器。您可能需要在標籤欄視圖控制器上設置視圖控制器數組,其中此導航控制器是數組中的項目之一。 –