Failover View Controller for a Special View Controller
Containers My View Login → Main Menu → A → B → C → D
How to shrink all view controllers and return to the main menu
For logging out of my view controllers I do the following which returns to Login
func logout{
self.view.window!.rootViewController?.dismissViewControllerAnimated(false, completion: nil)
}
Now what I do is
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;
}
}
+3
source to share
4 answers
You can use Unwind Segue if MainMenu is not your rootViewController. Take a look at this article, hope it helps. Unwind Segue with Swift
0
source to share