I have a tableview controller, a detail VC. and an edit detail VC that allows for deletion of an item. The Tableview is fed by an array of items.
Upon deletion of the item, I would like not only to dismiss the edit VC but also the detailVC underneath it (since the item no longer exists) leaving just the updated tableview.
I can successfully update the tableview with a notification and I can dismiss the edit view controller. However, I can't figure out a way to delete the detail VC after the edit VC disappears.
So far, after the deletion is confirmed from the server in the editVC I have:
[self dismissViewControllerAnimated: NO completion:nil];
[self.presentingViewController dismissViewControllerAnimated: YES completion: nil];
This dismisses the editVC but not the detail VC.
I also send a notification upon delete that is observed by both the tableview VC and the detail VC and the handler for both has similar dismissal code. I've tried in each:
[self dismissViewControllerAnimated: NO completion:nil];
[self.presentingViewController dismissViewControllerAnimated: YES completion: nil];
But the detail View still does not get dismissed.
Of note, the detail is a Show (e.g.) push and the Edit is a modal view controller embedded in its own nav.
VCs in Storyboard. The First nav is part of a TabViewController in the main storyboard
Edit:
If it makes any difference, the delete method in the third (edit) VC is called from an AlertViewController.
From Apple's documentation, merely calling dismissViewController should dismiss all later VCs in the navigation stack but that does not seem to be happening:
Discussion
The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, UIKit asks the presenting view controller to handle the dismissal. If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack. If you want to retain a reference to the view controller's presented view controller, get the value in the presentedViewController property before calling this method. The completion handler is called after the viewDidDisappear: method is called on the presented view controller.