我如何选择标签栏 Controller ?标签上有2个 View Controller ,其中包含导航 Controller ,标签栏 Controller 上有一个导航 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)

谢谢

最佳答案

Storyboard中,将标识符设置为UITabbarController,然后使用instantiateViewController表示该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)

关于ios - 实例化View Controller Swift 3 Tab Bar Controller,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42593088/

10-15 08:29