2017-03-04 181 views
2

如何繼續瀏覽標籤欄控制器? Theres 2視圖控制器帶有導航控制器的選項卡和選項卡欄控制器上的導航控制器。實例化視圖控制器Swift 3標籤欄控制器

let storyboard = UIStoryboard(name: "PendingOverview", bundle: nil) 
let vc = storyboard.instantiateViewController(withIdentifier: "PendingOverviewVC") as! PendingOverViewController 
let nc = UINavigationController(rootViewController: vc) 
self.present(nc, animated: false, completion: nil) 

謝謝

+0

您在問題中和代碼中使用了禮物時詢問過segue了嗎? –

+0

對不起,我在使用字面術語「segue」。雖然 – Denis

+0

感謝您嘗試我的解決方案是否適合您? –

回答

1

Storyboard集標識符到UITabbarController,然後使用本instantiateViewControllerUITabbarController

let storyboard = UIStoryboard(name: "PendingOverview", bundle: nil) 
let tabbarVC = storyboard.instantiateViewController(withIdentifier: "TabbarIdentifier") as! UITabbarController 
if let vcs = tabbarVC.viewControllers, 
    let nc = vcs.first as? UINavigationController, 
    let pendingOverVC = nc.topViewController as? PendingOverViewController { 

     pendingOverVC.pendingResult = pendingResult 
} 
self.present(tabbarVC, animated: false, completion: nil) 
+0

我該如何傳遞一個值,因爲我在終端視圖控制器上得到零 – Denis

+0

您想在哪個viewController上傳遞值first或second,並且這兩個viewController都嵌入到NavigationController中? –

+0

讓vc = storyboard.instantiateViewController(withIdentifier:「MyTabController」)爲? MyViewController vc.datatopass = datatopass – Denis

相關問題