Root View Controller gets changing after navigating from Main ViewController to another controller by push in swift
Opened this issue · 0 comments
anil-irestore commented
I have signup view in my application. After signup completes, I have Mainview Controller and I am making that as RootViewController with Slidemenucontroller.
Its working fine, but, after I am navigating from MainViewController to some other viewcontroller by doing push, once I pressed on Slidemenucontroller home button, its showing last pushed viewconroller instead of mainviewcontroller.
Even I set slidemenuviewcontroller with rootviewcontroller as Mainviewcontroller.
And I am using SlideMenuControllerSwift library to show slidemenu in my application.
Here is my code
// create viewController code...
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainViewController = storyboard.instantiateViewController(withIdentifier: "MainViewController") as! MainViewController
let leftViewController = storyboard.instantiateViewController(withIdentifier: "LeftViewController") as! LeftViewController
let nvc: UINavigationController = UINavigationController(rootViewController: mainViewController)
let navigationBarAppearace = UINavigationBar.appearance()
navigationBarAppearace.tintColor = UIColor.white
navigationBarAppearace.titleTextAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white]
leftViewController.mainViewController = nvc
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let slideMenuController = SlideMenuController(mainViewController:nvc, leftMenuViewController: leftViewController)
appDelegate.window?.rootViewController = slideMenuController
// slideMenuController.delegate = self as! SlideMenuControllerDelegate
appDelegate.window?.makeKeyAndVisible()
How to fix this?