Reputation: 65
I have an app that has a menu. Please check attached image below:
Now if I go to "Council" under "Municipality" which is a page. It gives me a screen with text and on the upper bar I have a back button.
The problem is that when I click on the back button, it brings me back to the home screen. I need it to bring me back to the same menu open position where I originally tapped on the menu item.
How to make this possible?
Upvotes: 0
Views: 1998
Reputation: 5477
If you are using UINavigationController use this:
if let navController = self.navigationController {
navController.popViewController(animated: true)
}
If you are presenting a view controller modally use this:
self.dismiss(animated: true, completion: nil
If you want to pop to rootViewController
(First view in navigation stack) use this:
if let navigationController = self.window?.rootViewController as?
UINavigationController {
navigationController.popToRootViewControllerAnimated(true)
}
If you are using any pod/library for side menu use their documentation or provide details in question so that we can help.
Upvotes: 3