unwind segue goes too far

I have a root View controller that present a second view controller modally. And then the second view controller will present a view controller with searchBarvia show segue.


If user type something in the searchBar a table view(which has no segue relationshop with the view controller in the storyboard) will show with its cells populated with all the possible address results. Here if a user tap any prefered cell I would like to perform an unwind segue to go back to second view controller.


So in override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) I do dismiss(animated: true, completion: nil) self.performSegue(withIdentifier: "backToNewTasks", sender: self)


But this way the segue will go back one step further to root View controller not second view controller.


I think the problem might be the view controller with searchBar has no segue relationship with the table view and the dismiss method has some impact on the views stack. but if I don’t use the dismiss method the segue won’t even happen.


I have done some research and found these

Programmatically defining a new navigation controller order/stack?

Calling function from another ViewController in swift

Why does my unwind segue go back too far?


But they did not really solve situations like mine.


Below is the link for the sample project:


Powered by WPeMatico


You may also like...

Comments are closed.