我的视图控制器 登录 -> 主菜单 -> A -> B -> C -> D
如何关闭所有视图控制器并返回主菜单
为了从我的视图控制器注销,我正在执行以下操作,这将带回到登录界面。
func logout{
self.view.window!.rootViewController?.dismissViewControllerAnimated(false, completion: nil)
}
现在我正在做的是这样的。
class AppDelegate: UIResponder, UIApplicationDelegate {
var viewControllerStack: [BaseViewController]!
}
override func viewDidLoad() {
super.viewDidLoad()
super.appDelegateBase.viewControllerStack.append(self)
}
func go_To_MainMenu(){
var countOfNumberOfViewCOntrollers = self.appDelegateBase.viewControllerStack.count
switch countOfNumberOfViewCOntrollers{
self.presentingViewController?.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
break;
case 2:
self.presentingViewController?.presentingViewController?.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
break;
}
}