Search code examples
iosobjective-cuiviewcontrollersegueuisplitviewcontroller

Why does my performSegueWithIdentifier end up without a back button?


For some reason when I do performSegueWithIdentifier from an add view, the back button is missing from the iPhone simulator.

This is a "Master-Detail Application" template, with the add button going to a new UIView. (The whole demo is on github)

Programmically clicked Programmically clicked

User clicked User clicked

My add view calls the following code on the table controller:

[self.navigationController popToRootViewControllerAnimated:NO];
//[self.navigationController popViewControllerAnimated:NO];

NSIndexPath* selectedCellIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:selectedCellIndexPath animated:false scrollPosition:UITableViewScrollPositionMiddle];
[self performSegueWithIdentifier: @"showDetail" sender:[self.tableView cellForRowAtIndexPath:selectedCellIndexPath]];

However running this code directly from the table view works without issue.

So I'm at a loss as to why the back button doesn't show up on the iPhone. (iPad version seems to work perfectly).


Solution

  • I've tried a few different strategies to solving my issue.

    The closest I've found is to display the add as a modal, segue to detail, unwind segue.

    It still suffers a little on iPad version, (the add button disappears on add), but works better than my original code.

    Solution on Github

    If anyone has a better solution, then I'm happy to change the accepted answer.