Unbalanced calls to begin/end appearance transitions for <FirstViewController: 0x2a2c00>

I have this problem when I simulate my app, its not an error or a warning but it appears in my console, has anyone ever experienced this before?


Solution 1:

In my case, this error occurs when you click two tabs in a tableview very fast.

The result causes wrong titlename, back button disappear. Someone mentioned that when you push a view, set animated:NO. The error will disappear but still causes some strange behavior. It pushes two views, then you need to back twice to get back the tableview screen.

Method I tried in order to resolve this problem:

add BOOL cellSelected;

in viewWillAppear cellSelected = YES;

in didselectcell delegate if (cellSelected){cellSelected = NO; do action ; }

This helps prevent clicking two different cells very fast.

Solution 2:

In my case it happened when I triggered [self performSegueWithIdentifier:@"SomeIdentifier" sender:self]; within a UINavigationController item's viewDidLoad method.

Moving it into the viewDidAppear method solved the problem.

The reason very likely is that in viewDidLoad not all of the fancy animations have already been finished, whereas in viewDidAppear everything's done.

Solution 3:

I have this problem too. I found two solutions to this problem:

  1. You can see this solution above.
  2. I found subclass from UINavigationController where this problem resolved. Buffered Navigation Controller

Solution 4:

You should run your code in different loop to avoid this

 double delayInSeconds = 0.1;
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            // Put your code here
[self presentViewController:self.yourModalVC animated:YES completion:nil];
        });

Solution 5:

I had lot of problem with the same issue. I solved this by this way

1) You're not using UIViewController's designated initializer initWithNibName:bundle:. Try using it instead of just init.

2) set animated:YES to a NO, and that solved the problem. eg. [self.navigationController pushViewController: viewController_Obj animated:NO];