Search code examples
iosmodal-dialoguisplitviewcontrolleruistoryboardsegue

Modal unwind segue not working with apple's MutlipleDetailViews


I am using Apple's multiple detail views example to set up an iPad split view controller app with a master controller - a tab view each tab containing a table view... However in each of these tab views I also want to give the user the option to click an add button which calls a modal segue to add a new instance of the CoreData object which is providing data for the table view under that tab. The only problem I'm having is that when I link up the unwind segue from the ViewController which is segued to modally the unwind method gets called, but doesn't remove the ViewController from the screen.

My first idea was to try calling

[self.navigationController dismissViewControllerAnimated:YES completion:^{}];

Within the unwind method, which works - however when you next click the add button again you get a EXC_BAD_ACCESS (code = 1, adress==...) error, which is strange as nothing surely the app shouldn't be trying to access any objects which may have been dealloc'd but simply init'ing a new instance of the modal view controller from the Storyboard?

Any help would be greatly appreciated!


Solution

  • I had the same issue ... If it is a modal segue you were calling first, then you could maybe try to call dismissViewControllerAnimated: from self, not from self.navigationController :

    [self dismissViewControllerAnimated:YES completion:nil];