iPhone UINavigation Issue - nested push animation can result in corrupted navigation bar

后端 未结 20 1893
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 20:14

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         


        
相关标签:
20条回答
  • 2020-11-30 20:53

    Um I had this issue, and Im new to the whole iOS dev scene. But after looking at my connections inspector (with file's owner) in the interface builder i saw that as I had copied a button it had the previous buttons method assigned to it as well as the new method I had created. I guess that was where the nested aspect of my problem came from, as it was executing 2 different methods both of which pushed a view onto the Nav Controller. I know this has already been answered but I figured I would put this up just in case anyone else had a silly mistake like mine.

    0 讨论(0)
  • 2020-11-30 20:55

    Recently, I've faced the same problem. The reason was: -I was trying to pop view controller twice by mistake. you can check this crash by setting breakpoints on push and pop View controllers

    0 讨论(0)
  • 2020-11-30 20:56

    My problem had to do with the keyboard being active.

    This was caused for me by pushing a ViewController from a textField's 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 went away.

    Basically the lesson is that you shouldn't modify the navigationController stack if the keyboard is out.

    0 讨论(0)
  • 2020-11-30 20:58

    This has already been answered, but I thought this might help others as I got the same error but without using table views. I finally figured out the problem.

    I had an existing button whose IBAction invoked a pushViewController. I had created a new button by copying the existing button. The new button also had an action that invoked pushViewController. When the new button was tapped (touch up inside) and the view controller was pushed, I got this error. I deleted the new button, created it from scratch, bound it to the existing outlets and actions, and the error went away.

    0 讨论(0)
  • 2020-11-30 20:58

    In my case I was both setting the push segue from the storyboard and programatically. Hopefully that'll help anyone

    0 讨论(0)
  • 2020-11-30 21:00

    ACCIDENTLY TRIGGERING THE SAME SEGUE TWICE Once in code, and once from interface builder, but both at the same time...

    I was getting the same error as the rest of you. Only my problem was I was accidentally firing the same segue, twice. Once from interface builder, and once from within my code.

    I have a UITableView. When a cell is selected, a segue in interface builder fires. Heres my problem, I had the segue set up to be directly fired off clicking the CELL ITSELf, inside interface builder, then in my code, I had under didSelectRowAtIndexPath, code that would fire that same segue... like so...

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

    That means when didSelectRowAtIndexPath gets called because a row was selected, it fires the segue with the above line of code. Then interface builder, also triggers the segue, because its connected directly to the cell object in interface builder. To stop interface builder from directly firing the segue. You have to connect the segue from the top of the view controller, not nested down inside coming off of the cell itself.

    So if you are having this problem for the same reason as me, that is, you are calling the same segue twice, you can fix this by unlinking the connection from the CELL DIRECTLY, to your segue, and having the segue connection originate at the top of the table hierarchy in IB, rather than nested inside the cell. Connect the segue from you View Controller itself, to the segue. If you have done this correct, when you select the segue, it should highlight the ENTIRE view it is coming from, not just the cell.

    Now Apples documentation states thus under the performSegueWithIdentifier:sender: reference:

    Apps normally do not need to trigger segues directly. Instead, you configure an object in Interface Builder associated with the view controller, such as a control embedded in its view hierarchy, to trigger the segue. However, you can call this method to trigger a segue programmatically, perhaps in response to some action that cannot be specified in the storyboard resource file. For example, you might call it from a custom action handler used to process shake or accelerometer events.

    In my case, I have a search button for my UITableView, and whether the segue is called when the search results table is present, or the normal table view is present, had to be determined. So I needed to trigger the segue directly.

    So remove the embedded control from interface builder, and just stick it on the view controller itself, then trigger the segue in your code!

    Now, no more double segues! And no more errors.

    Hope that helps, took me a good few hours to tackle this one.

    0 讨论(0)
提交回复
热议问题