0
我想知道如何检查当前显示的视图控制器。Swift ios检查哪个视图控制器存在
当用户收到通知并按下它时,我想让用户使用某个VC。但只有当用户不在那里。
我使用的这个时候,我收到了通知:
if let tabBarController = self.window!.rootViewController as? CustomTabBarController {
let navInTab:UINavigationController = tabBarController.viewControllers?[0] as! UINavigationController
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationViewController = storyboard.instantiateViewController(withIdentifier: "EventVc") as? EventsViewController
navInTab.pushViewController(destinationViewController!, animated: true)
tabBarController.selectedIndex = 0
}
我不想,如果用户已经是EventVc
而且运行这段代码,我可以运行上面,如果代码用户已经在选项卡0但在与EventVc不同的VC?
而如果是任何帮助我的应用程序是建立这样的:
(根)的TabBar
(TAB1) - >导航器 - > VC - > VC ...
( TAB2) - >导航控制器 - > VC - > VC ...
(TAB3) - >导航控制器 - > VC - > VC ...
(TAB4) - >导航控制器 - > VC - > vc ...
没有我的回答解决问题了吗? – emresancaktar