实例化View Controller Swift 3标签栏控制器
如何切换到标签栏控制器? Theres 2在选项卡上查看带有导航控制器和标签栏控制器上的导航控制器的控制器。
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)