I have small app with 5 screens that are embedded in Navigation stack and I can't dismiss UIViewController
I'm using SideMenu in my project to present last UIViewController
from it, here's a code configuration of side menu:
SideMenuManager.default.menuPushStyle = .replace
SideMenuManager.default.menuPresentMode = .menuSlideIn
And the way how I'm presenting VC:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "menuToSavedQuotes" {
_ = segue.destination as? SavedQuotesViewController
}
}
And then: self.performSegue(withIdentifier: "menuToSavedQuotes", sender: self)
It works just fine, but then when I call action for dismissing - this doesn't work. I'm not using nav bar in my app, that's why I created button and tried to dismiss it but failed.
What I tried is:
self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: nil)
But none of this worked. What I have right now and still not working is:
override func viewDidLoad() {
super.viewDidLoad()
output?.viewIsReady()
setupNavigationStack()
}
@IBAction func didPressClose(_ sender: UIButton) {
print("Here")
self.navigationController?.popViewController(animated: true)
//self.dismiss(animated: true, completion: nil)
}
func setupNavigationStack() {
if let root = UIApplication.shared.keyWindow?.rootViewController as? StartingPageViewController {
let navigation = root.childViewControllers[0] as! UINavigationController
let vc1 = self.storyboard!.instantiateViewController(withIdentifier: "StartingPage")
let vc2 = self.storyboard!.instantiateViewController(withIdentifier: "StartTrial")
let vc3 = self.storyboard!.instantiateViewController(withIdentifier: "ScheduleNotifications")
let vc4 = self.storyboard!.instantiateViewController(withIdentifier: "AllQuotes")
let vc5 = self.storyboard!.instantiateViewController(withIdentifier: "SavedQuotes")
navigation.setViewControllers([vc1, vc2, vc3, vc4, vc5], animated: true)
}
}
As a temporary solution my close button just opens previous UIViewController
but this is not a good practice.
Would be grateful for any help!
Thanks!
After searching for a while I still could not locate source of my issue so I stayed with workaround:
Close button just opens previous UIViewController
but this is not a good practice.
In my case application has only 3 screens and it's fine, but if to talk about bigger apps such solution is not recommended.