Reputation:
I have use the following code below . to navigate but i have tried all possible idea i have to navigate back but i always received an error. like Warning: Attempt to present on whose view is not in the window . when using the code below what is the best way to navigate back ? or to go to another view?
if let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ScoreViewController") as? ScoreViewController
{
present(vc, animated: true, completion: nil)
}
Upvotes: 0
Views: 58
Reputation: 6555
If you are using NavigationController to push one ViewController to other then for navigate back you have to use Pop like this,
self.navigationController?.popViewController(animated: true)
and if you are using Modal Controller to present another Controller then for navigate back you have to use dismiss like this,
dismiss(animated: true, completion: nil)
Let me know in case of any queries.
Upvotes: 1
Reputation: 8506
You are presenting the view controller not pushing it. To come back to the controller, write down the below controller:-
dismiss(animated: true, completion: nil)
Upvotes: 0