First of all I am using storyboard. My ViewController hierarchy like this NavigationController -> SplashScreen -> LoginScreen -> MainTabBarController -> MainNavigationController -> MainViewController -> DetailViewController
.
When I click a button on the DetailViewController
page does not back to MainViewController
. It is going to LoginScreen
.
I tried this codes within addToBasket
action in DetailViewController
.
@IBAction func addBasket(_ sender: Any) {
SingletonCart.sharedFood.food.append(food!)
let mainView = self.storyboard?.instantiateViewController(withIdentifier: "FoodOrder") as! MainViewController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
self.navigationController?.popViewController(animated: true)
dismiss(animated: true)
}
Here is my loginButton
codes for make MyTabBarController
as rootViewController.
@IBAction func loginButton(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "MainTabBarController")
self.window?.rootViewController = viewController
}