I have a tableview, and as soon as anyone presses a cell, the viewcontroller should pop. This is the code for my tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) method:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//previously written code
navigationController?.popViewController(animated: true)
}
Everything works fine, except for one case: as soon as view loaded, i try to press on any cell immediately. In that situation popViewController isn't executed and i get this error:
popViewControllerAnimated: called on UINavigationController while an existing transition or presentation is occurring; the navigation stack will not be updated.
I know, this question appeared before on StackOverflow, but i didn't find any other solution than:
DispatchQueue.main.asyncAfter(deadline: .now() + //time) {
navigationController?.popViewController(animated: true)
}
It works great, but i don't need a delay when pressing on tableview cell. As soon as presentation is over, popViewController works as required and delay in execution isn't needed.
Is there another way to make this happen? Or somehow get a notification, when the transition is ready, so i can pop afterwards?