5

I have a UINavigationController which goes into a ViewController that loads data. This ViewController then segues to TabViewController. This TabViewController has two tabs, each Tab goes to a different UITableViewController. Those two TableViewController then segue to the same DetailsViewController.
Now when navigating backwards from the DetailVC I get this error:

nested push animation can result in corrupted navigation bar
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't add self as subview'.

Also both TableViews are set up the same way but the bottom table view begins at the top of the frame so its partial obscured by the navigation bar.

Snick
  • 115
  • 1
  • 10
  • 1
    I would love to post code but I believe this is a structural issue im dealing with here. Dont know exactly what code to post that would be helpful. Tried to post an image of my storyboard but I need more rep points to do so. Besides I am already home... – Snick Nov 10 '13 at 22:11
  • 2
    Figured it out. The segue was being performed twice in each UITableViewController. Once from the cell itself and again on didSelectRowAtIndexPath. – Snick Nov 11 '13 at 03:13

1 Answers1

2

I have a table view and a search bar controller on it.I created push segue on table view cell and performed push on selecting search item via search controller programatically.When navigated back exception fired.This exception happens when you perform same segue twice at a time.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
(NSIndexPath*)indexPath
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{

    [self performSegueWithIdentifier:@"showDetail"sender:self];
}
}

Since it was performing same segue twice one for table view cell selection created in storyboard and another for search result cell selection. So check when to perform segue

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
if (self.tableView == self.searchDisplayController.searchResultsTableView)
{

    [self performSegueWithIdentifier:@"showDetail"sender:self];
    return YES;
}

return NO;
}

This worked perfectly.

iGauravK
  • 91
  • 7
  • 1
    Hey - a big thank you from my side. I had the same problem which caused me some headache! I posted an answer to my question here: http://stackoverflow.com/a/20827783/2580805, with a backreference to this question/answer. – DerWOK Dec 29 '13 at 17:09
  • I'm facing same problem, and i'm not using story board. how to fix at code level. Please let me know if you need any code info – selva Aug 18 '14 at 07:09
  • It might be possible, that you may be pushing ViewController before appearing the view i.e viewDidAppear in your code.Please refer the [link](http://stackoverflow.com/questions/5525519/iphone-uinavigation-issue-nested-push-animation-can-result-in-corrupted-naviga). – iGauravK Aug 19 '14 at 10:41