Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: nested push animation can result in corrupted navigation bar

Tags:

ios

ios7

i am new to ios. i am working on a project but stuck at this error.

basically the below code is to load a new xib when a row is clicked, if statement is used to check wether a specific row is clicked.

if (#something) {
    UIViewController *controller = [[NSClassFromString(@"abcd") alloc] initWithNibName:@"abcd" bundle:nil];
    [self.navigationController pushViewController:controller animated:YES];
} else {
    methodsViewController.r = [sel objectForKey:@"cvb"];
    methodsViewController.m = [sel objectForKey:@"bnm"];
    #adding controller
    [self.navigationController pushViewController:controller animated:NO];
}

the problem is that when i click on an row it goes to the new page but when i click the back button in the navigation bar, the previous page does not load but instead shows a black page. the error it shows in the log is: 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.

I searched all the similar answer but could not get the solution. help will be greatly appreciated.

thanks in advance

like image 349
George Avatar asked May 19 '14 10:05

George


2 Answers

You may have a Segue in the Storyboard which triggers when a table row is selected. When you also manually push a controller when a row is selected the error which you describe occurs. You should remove the segue from the storyboard.

EDIT: More details:

I assume you use a storyboard (more than one view controller in the design window). If you do not use it, I am on the wrong track. For example take this screenshot from one of my projects:

Storyboard screenshot

If you have control-dragged from the "Row" to the view controller on the right, you created a segue. It is likely that this segue is triggered when you select a row in the tableview in the left view controller. If you used a standard project, such a segue may already exist and you did not create it yourself.

The segue fires "automatically" when you select a row. When you manually push view controllers in code, you may cause a "second push" which disturbs the navigation controller.

You could just delete the segue by clicking on the thick line between the scenes or on that round icon and press delete.


If you need a segue which does not automatically trigger when a row is selected, you can control-drag it from that yellow icon to the target scene. A menu should appear and you would choose one of the options under "manual". Then the segue must be triggered manually which you would do in code with:

[self performSegueWithIdentifier:@"SegueId" sender:self];

When you click on the round segue icon in the storyboard, you can set an identifier in the utilities window in the attributes inspector in the field "Identifier". That identifier is the string used in the code line above.

like image 98
Rainer Schwarze Avatar answered Nov 01 '22 14:11

Rainer Schwarze


I got caught with this one by forgetting to insert a break; after a case: in a switch() statement. Each case: had a [self performSegueWithIdentifier:... I was falling through to the next case and executing 2 of these Segue performers.

like image 29
Seoras Avatar answered Nov 01 '22 16:11

Seoras