【发布时间】:2017-04-21 10:47:22
【问题描述】:
当用户单击某个单元格上的按钮时(视图) 我想推到另一个标签的视图控制器
标签栏控制器
--- 导航控制器 ---- VC A
--- 导航控制器 ---- VC B
--- 导航控制器 ---- VC C ---- VC D
like 从 viewcontroller A 到 viewcontroller D
我试过转场
self.window?.visibleViewController?.performSegue(withIdentifier:"homeSegueDetailStatement", sender: self)
工作但没有导航栏....
我尝试创建一个导航控制器并显示,崩溃了...
if let visibleViewCtrl = UIApplication.shared.keyWindow?.visibleViewController {
let nav = UINavigationController(rootViewController: visibleViewCtrl)
let b = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PendingStatementVC") as! PendingStatementViewController
nav.pushViewController(b, animated:false)
visibleViewCtrl.present(nav, animated:true, completion:nil)
}
请帮帮我
编辑---
实际上我想将选项卡和导航更改为第二个视图控制器。 我从 collectionCell 调用这个函数,这就是为什么我必须获取当前视图控制器
编辑--- 我找到了我想要的
DispatchQueue.global().async {
DispatchQueue.main.async {
self.tabBarController?.selectedIndex = 2
if let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DetailStatementVC") as? DetailStatementViewController {
if let navigator = self.tabBarController?.viewControllers?[2] as? UINavigationController {
navigator.pushViewController(controller, animated: true)
}
}
}
}
【问题讨论】:
-
如果你推视图控制器,那你为什么要再次展示视图控制器
-
你需要从 appdelegate 或 Viewcontroller 推送?
-
你能展示你的故事板场景吗
标签: ios swift uinavigationcontroller uitabbarcontroller