简体   繁体   中英

Instantiate View Controller Swift 3 Tab Bar Controller

How can I segue to a tab bar controller? Theres 2 view controllers on tabs with navigation controllers and a navigation controller on the tab bar controller.

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)

Thank you

In Storyboard set identifier to UITabbarController and then using instantiateViewController present that UITabbarController .

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM