IPhone UINavigation Issue - Nested push animations can damage the navigation bar

I keep getting the following errors:

2011-04-02 14:55:23.350 AppName[42430:207] nested push animation can result in corrupted navigation bar 2011-04-02 14:55:23.352 AppName[42430:207] nested push animation can result in corrupted navigation bar 2011-04-02 14:55:23.729 AppName[42430:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted. 2011-04-02 14:55:23.729 AppName[42430:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted. 

That's what I'm doing. From the view controller, I call the following when some button is pressed:

 EventsViewController *viewController = [[EventsViewController alloc] init]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController]; navController.navigationBar.tintColor = [UIColor blackColor]; [self presentModalViewController:navController animated:YES]; [viewController release]; [navController release]; 

Then, if some button is pressed in the EventController, I call:

 SingleEventViewController *viewController = [[SingleEventViewController alloc] initWithEvent:[currentEvents objectAtIndex:indexPath.row]]; [self.navigationController pushViewController:viewController animated:YES]; [viewController release]; 

Then, if some button is pressed in the SingleEventViewController, I call:

 EventMapView* viewController = [[EventMapView alloc] initWithCoordinates]; [[self navigationController] pushViewController:viewController animated:YES]; [viewController release]; 

So it’s obvious that nested animations are push, but isn't that the right way? I checked the Apple DrillDownSave code and it looks like it does. Does it matter that I use init methods instead of viewDidLoad methods?

+68
iphone ios4 uinavigationcontroller navigationcontroller
Apr 02 '11 at 20:00
source share
20 answers

I get it. Obviously, if you call -pushViewController because of the -didSelectRowAtIndexPath UITableViewDelegate method, it does not work. Moving a call to this function worked. Weird

+10
Apr 09 '11 at 19:51
source share

Calling pushViewController before viewDidAppear unsafe.

+114
Jul 13 2018-11-11T00:
source share

IT SHOULD BE TRAINED BY A SINGLE SEGEWAY TWICE Once in the code and once from the interface constructor, but both at the same time ...

I was getting the same error as everyone else. Only my problem was that I accidentally shot the same session twice. Once from the interface constructor and once from within my code.

I have a UITableView. When a cell is selected, the segue in interface script is fired. Heres my problem, I had a segue setting to be fired directly by clicking CELL ITSELf, the built-in interface constructor, and then in my code, which I had in the didSelectRowAtIndexPath file, which could burn the same ... so .. .

 [self performSegueWithIdentifier:@"MySegue" sender:tableView]; 

This means that when didSelectRowAtIndexPath is called because a row has been selected, it starts segue with the above line of code. Then the interface builder also runs segue because it is directly connected to the cell object in the interface builder. Stop the interface builder from directly starting segue mode. You must connect segue from the top of the view controller, not nested inside, exiting the cell itself.

So, if you have this problem for the same reason as mine, that is, you are invoking the same session twice, you can fix this by canceling the connection to CELL DIRECTLY, before your segue and having the segue connection start at the top parts of the table hierarchy in IB, not nested inside the cell. Connect the segue to the View Controller itself, before moving on. If you did it right, when you select segue, it should highlight the ENTIRE view it comes from, not just the cell.

Currently, the apple documentation is thus in the executeSegueWithIdentifier: sender: reference file:

Applications usually do not need to run segues directly. Instead, you configure an object in Interface Builder that is associated with a view controller, such as a control built into its view hierarchy, to run segue. However, you can call this method to invoke segue programmatically, perhaps in response to some actions that cannot be specified in the storyboard resource file. For example, you can call it from a special action handler used to handle shaking events or an accelerometer.

In my case, I have a search button for my UITableView, and whether it was necessary to call segue when there is a search result table, or a regular table lookup, it was necessary to determine. Therefore, I had to immediately call a shogi.

So, remove the inline control from the interface builder and just bind it to the view controller itself, then activate segue in your code!

Now, no more double transitions! And no more mistakes.

Hope this helps, I spent several hours doing this.

+92
Jan 19 '13 at 10:13
source share

I had the same problem / error message as now, searched for a solution and got into this thread, however for me I found that in fact the solution has only one animated: YES, when you do a nested push (I add animated : YES just for the last click), hope this helps

greetings.

+11
Apr 11 2018-11-11T00:
source share

I ran into the same problem that arose because the button on the tip is connected to two different actions. He tried to load both view controllers, thereby damaging the stack.

+8
Feb 20 2018-12-12T00:
source share

What do you mean when you say you use init methods instead of viewDidLoad methods?

If you press the new view controller before the old push has a poor ability to act, you will get this error. Thus, including certain code in init and executing something prematurely could give you an error message.

The moment init starts on the view controller, the view is not loaded yet!

+4
Apr 3 2018-11-11T00: 00Z
source share

I had this problem and I became new to the whole iOS scene. But, looking at the inspector of my connections (with the file owner) in the interface builder, I saw that when I copied the button, it had the method of previous buttons assigned to it, as well as the new method that I created. I assume that it was here that the nested side of my problem arose, as it performed two different methods, both of which pushed the view on the Nav Controller. I know that this has already been answered, but I thought that I would put it just in case, if someone had a stupid mistake like mine.

+2
02 Oct. '13 at 14:57
source share

This has already been answered, but I thought it might help others, since I got the same error, but without using table views. I finally understood the problem.

I had an existing button whose IBAction called pushViewController. I created a new button by copying an existing button. The new button also had an action that called pushViewController. When a new button was pressed (touch inside) and the view controller was pressed, I got this error. I deleted the new button, created it from scratch, linked it to existing outputs and actions, and the error disappeared.

+1
Jul 17 2018-12-12T00:
source share

Get in the same problem. In my case, I missed a break in the switch statement, so two segues were released at the same time. Easy fix for me.

+1
Jun 09 '13 at 12:07 on
source share

My problem is keyboard activity.

This was triggered for me by clicking ViewController from the textField delegate method:

 -(void)textFieldDidBeginEditing:(UITextField *)textField{ FilterLocationViewController *destViewController = (FilterLocationViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"FilterLocationViewController"]; [self.navigationController pushViewController:destViewController animated:YES]; } 

By changing the code to this:

 -(void)textFieldDidBeginEditing:(UITextField *)textField{ [_textFieldLocation resignFirstResponder]; //adding this line FilterLocationViewController *destViewController = (FilterLocationViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"FilterLocationViewController"]; [self.navigationController pushViewController:destViewController animated:YES]; } 

(adding the line [textField resignFirstResponder]; ) the problem disappeared.

The main lesson is that you should not change the navigationController stack if the keyboard is missing.

+1
Apr 02 '14 at 2:49
source share

I recently ran into the same problem. The reason is that: - I tried to mistakenly try to configure the view controller. you can verify this failure by setting breakpoints on the push and pop View controllers

+1
Jul 31 '14 at 9:06
source share

1) Perhaps you could try passing the necessary variables as properties before clicking on the UIViewController rather than using init methods with parameters. Most likely, you will need these parameters outside the init method.

Also, your initWithCoordinates: missing parameters. Perhaps your custom init methods are part of the problem.

2) Just because you mentioned viewDidLoad - this method is designed to initialize after loading the view. If you create a UIViewController in code, it seems to you that you should use loadView to configure your subzones.

0
Apr 03 2018-11-11T00:
source share

My decision was

[self performSelector: @selector (moveTo) withObject: nil afterDelay: 0.5];

0
Apr 3 '13 at 14:39
source share

This was happening to me because of my UIControlEvents

  [button addTarget:self action:@selector(callSecondView) forControlEvents:UIControlEventAllTouchEvents]; 

I had to change UIControlEventAllTouchEvents to UIControlEventTouchUpInside or you still want your button to work if you have a problem due to calling UIButton.

0
Jul 11 '13 at 18:32
source share

I don’t know about others. I think most people using StoryBoard are faced with such a problem. I am using XIB.

In my case, the Problem was when I moved to another view using push, I also used

  [self.navigationController popViewControllerAnimated:YES]; 

in ViewWillDisappear of the current view at the same time. Just delete it and it works great.

I used POP due to requirement and flow. The hierarchy was 1 β†’ 2 β†’ 3

I was in sight 2 and wanted to go to view 3. In this case, I ran into this error.

0
May 19 '14 at 10:55
source share

In my case, I both set up the push sega from the storyboard and programmatically. Hope this helps someone

0
Aug 20 '14 at 2:40
source share

I also had this error message, and the navigation bar and navigation controller transitions were strange. My setup was a bunch of navigation controllers built into the tab bar controller. The problem was that I did not call super.viewDidLoad() in my implementation of the Controlbar Tab viewDidLoad .

The super call is that the docs clearly indicate what you should do by overriding viewDidLoad, and I complicated it.

Perhaps this will also help someone else!

0
09 Oct '14 at 14:11
source share

I know this was answered, but it can help others.

I had the same problem, but it was caused by the fact that I used a bad event for the info button. I used "UIControlEventAllTouchEvents" and this generated two clicks of the same view in the navigation controller. The correct event was "UIControlEventTouchUpInside". I am new to iOS.

0
Dec 05 '14 at 12:05
source share

This solves the problem: https://github.com/nexuspod/SafeTransition

If you press (or pop) a view controller with an animation (animated: YES), it will not be completed right away, and bad things will happen if you do another push or pop before the animation finishes.

To reproduce this error, try simultaneously pressing or displaying two view controllers. Example:

 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; UIViewController *vc = [[UIViewController alloc] init]; [self.navigationController pushViewController:vc animated:YES]; } 

You will get this error:

2014-07-03 11: 54: 25.051 Demo [2840: 60b] nested push animation cause damage to the navigation bar 2014-07-03 11: 54: 25.406 Demo [2840: 60b] Completion of the navigation transition to an unexpected state. The navigation tree's visibility tree may be damaged.

Just add the code files to your project and make your navigation controller a subclass of APBaseNavigationController, and you will be good to do.

-one
Jul 05 '14 at 16:32
source share

Just to complete the list, here is another reason that could lead to the fact that "nested push animations can lead to a damaged navigation bar":

I installed several NavigationController in TabBarController and set selectedIndex in the Identifiy Properties drop-down list. After moving the active tab, the Code Error disappeared.

-one
Apr 29 '16 at 19:00
source share



All Articles