I have been trying to pop my view controller to one of previous view controllers in my view stack. Assume that, There are firstVC, secondVC, thirdVC and fourthVC
Instead of doing a generic popViewControllerAnimated:
call, use popToViewController:animated:
. You could detect if the user has deleted all of the rows in which case, do something like this (otherwise just pop one view controller):
let viewControllers: [UIViewController] = self.navigationController!.viewControllers as [UIViewController];
self.navigationController!.popToViewController(viewControllers[viewControllers.count - 2], animated: true);