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

IphoneIosTransition

Iphone Problem Overview


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?

Iphone Solutions


Solution 1 - Iphone

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 - Iphone

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 - Iphone

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 - Iphone

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 - Iphone

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];

Solution 6 - Iphone

I had the same issue using navigation controller and push other controllers to it. I tried to use Buffered Navigation Controller and several other approaches, but it didn't work for me. After spending some time for figuring it out I noticed that this issue occurs if you trying to push new view controller while previous transaction (animation) in progress (about 0.5 sec duration I guess). Anyway, I made quick solution with delegating navigation controller and waiting for previous animation finishes.

Solution 7 - Iphone

Ensure that you do not forget to in -viewWillAppear, -viewDidAppear, -viewDidLoad, -viewWillDisappear, -viewDidDisappear to call proper super method in your overload of that methods. For example in my case I mismatched method name like this:

-(void)viewDidAppear
{
 [super viewDidDisappear];
 //some code staff
 ..
}

notice that appear and disappear methods are mismatched

Solution 8 - Iphone

'Unbalanced calls to begin/end appearance transitions for '

Says an animation is started before the last related animation isn't done. So, are you popping any view controller before pushing the new one ? Or may be popping to root ? if yes try doing so without animation i.e. [self.navigationController popToRootViewControllerAnimated:NO];

And see if this resolves the issue, In my case this did the trick.

Solution 9 - Iphone

I had a similar problem that involved rewinding modal dialogs. Posted the solution here...

https://stackoverflow.com/a/38795258/324479

[Problem]

Nav Controller -> VC1 -Push--> VC2 -PopOver or Modal Segue--> VC3.

VC3 is unwinding back to VC1.

When the Segue from VC2 to VC3 is PopOver and Modal, the unwind ends in a warning: Unbalanced calls to begin/end appearance transitions for UIViewController"

If the Segue from VC to VC is push, the warning is gone.

[Solution]

It would be great if the unwind logic would take care of this. Maybe it's a bug, maybe not. Either way, the solution is to make VC2 (The controller that has the popup) the target of the rewind, then wait for it to finish appearing before popping up the nav controller. That ensures the rewind (reverse popup) animation has enough time to finish before moving further back. Even with the animations off, it still has to wait or else you get the error.

Your code for VC2 should be as follows. (Swift)

class VC2: UIViewController {
    private var unwind = false
    @IBAction func unwindToVC1(segue:UIStoryboardSegue) {
    	unwind = true
    }

    override func viewWillAppear(animated: Bool) {
    	super.viewWillAppear(animated)

	    if unwind {
	    	self.navigationController?.popViewControllerAnimated(false)
	    }
    }
}

Solution 10 - Iphone

I got this issue because I was calling a UIPrintInteractionController from a viewController without UITabbar, and neither UINavigationBar. It seems that the UIPrintInteractionController didn't get the correct printInteractionControllerParentViewController. Implementing the method in the delegate and return the current rootViewController worked for me.

    - (UIViewController*)printInteractionControllerParentViewController:(UIPrintInteractionController*)printInteractionController;

Solution 11 - Iphone

The situation can occur if you are adding a view with a modal view controller as a sub view. Best to use:

-(void) viewDidAppear:(BOOL)animated {
    [self presentViewController:self.yourModalVC animated:YES completion:nil];
}

It is basically saying the view life cycle is not streamlined for those viewControllers you are trying to display then.

Solution 12 - Iphone

I have the similar problem when trying to do:

[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
   

in a function like - (void) popUpToLevelTwo; , and to put a return; at the end of function solves the problem

Solution 13 - Iphone

For what it's worth, I got this same error when not including a call to [super viewDidLoad:animated] in my viewDidLoad override.

Solution 14 - Iphone

I also got this at

[self dismissModalViewControllerAnimated:YES];

I changed the YES to a NO, and that solved the problem.

Solution 15 - Iphone

i have same problem when i used navigationcontroller's pop method In my app i use a separate logic for navigation controller,So avoided the use of navigation bar and it is always hidden. Then i use a custom view and notification for handling the backbutton and it's events. notification observers are registered and and not removed. So the notification fires twice, and it creates the above mentioned error. Check your code throughly for getting such fault's

Solution 16 - Iphone

I also had this problem when I tapped a button from a NIB. It turns out I had accidentally wired the button to send an event to two IBAction methods, each of which did a pushViewController:animated:

Solution 17 - Iphone

I had some logic implemented to wait pushing the UIViewController until all data was downloaded. There was an error in this logic which caused to push the UIViewController too early while there was still another API call in progress.

It caused the same UIViewController to be pushed twice by the UINavigationController and gave this warning.

Solution 18 - Iphone

Reason For message: This message get displayed if and only if you are pushing/presenting another View controller from viewWillAppear,loadView,init or viewDidLoad method of current View Controller

Way to Remove error Message: Move your pushing/presenting code to viewDidAppear method will solve the issue

Solution 19 - Iphone

Swift 4

My issue was that I was presenting another VC before my current one finished to be rendered .

Solution was to present my nextVC after a quick delay.

WHAT YOU SHOULD NOT DO

override func viewDidLoad() {
    super.viewDidLoad() 
    self.present(MyNextVC(), animated: true, completion: nil)
}

WHAT YOU SHOULD DO

override func viewDidLoad() {
    super.viewDidLoad() 
    //Wait until the view finished to be constructed
    perform(#selector(showMyNextVC), with: nil, afterDelay: 0.01)
}

@objc func showCityList() {
    self.present(MyNextVC(), animated: true, completion: nil)
}


Solution 20 - Iphone

I had this problem when I forget to set Break; after pushing the view in a switch statement!

Like here:

case 1:{
        
        SomeViewController *someViewController = [[SomeViewController alloc]initWithNibName:@"SomeViewController" bundle:Nil];
        [self.navigationController pushViewController:someViewController animated:YES];
        [someViewController release];
    }

        break; //Forgetting to set break here:

Solution 21 - Iphone

the reason behind the error " Unbalanced calls to begin/end appearance transitions" is when you navigate | segue twice at the same time

Solution 22 - Iphone

one solution would be,

[NSTimer scheduledTimerWithTimeInterval:0.05(or as required) target:self
selector:@selector(your_selector_method_to_push_the_view) userInfo:nil repeats:NO];

Solution 23 - Iphone

You can run into this if you try to dismiss a UIViewController before it is finished loading.

I had this message in the console and was focusing entirely on the UIViewController that was presenting the new UIViewController, without success. I finally discovered the problem was in the UIViewController I was presenting was dismissing itself because the user wasn't logged into their account.

Hope this helps someone.

Solution 24 - Iphone

This was a tough one for me: I've overridden

override func shouldAutomaticallyForwardRotationMethods() -> Bool {
    return true
}

without overriding:

override func shouldAutomaticallyForwardAppearanceMethods() -> Bool {
    return true
}

in my window root navigation controller. then a child navigation controller complained when pushing another view controller with the above mentioned warning. The warning wasn't the worst, the big problem was, that there the delegate of the child navigation controller weren't called anymore. weired.

Solution 25 - Iphone

In my case I was fetching NSData from NSURL inside 'viewDidLoad' method.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionC.JohnsView Question on Stackoverflow
Solution 1 - Iphonechings228View Answer on Stackoverflow
Solution 2 - IphonetttthomasssssView Answer on Stackoverflow
Solution 3 - IphoneIgor_CodabraSoftView Answer on Stackoverflow
Solution 4 - IphoneprohuutuanView Answer on Stackoverflow
Solution 5 - IphonekunalgView Answer on Stackoverflow
Solution 6 - IphonedimanitmView Answer on Stackoverflow
Solution 7 - IphoneNikolay ShubenkovView Answer on Stackoverflow
Solution 8 - IphoneinfiniteLoopView Answer on Stackoverflow
Solution 9 - IphoneCarter MedlinView Answer on Stackoverflow
Solution 10 - IphonebalookaView Answer on Stackoverflow
Solution 11 - IphoneelliotrockView Answer on Stackoverflow
Solution 12 - IphoneBabyPandaView Answer on Stackoverflow
Solution 13 - IphoneraeldorView Answer on Stackoverflow
Solution 14 - IphoneDD.amorView Answer on Stackoverflow
Solution 15 - IphoneDileep stanleyView Answer on Stackoverflow
Solution 16 - IphoneMartin LockettView Answer on Stackoverflow
Solution 17 - IphoneJasperView Answer on Stackoverflow
Solution 18 - IphoneMehul ThakkarView Answer on Stackoverflow
Solution 19 - IphoneUgo MarinelliView Answer on Stackoverflow
Solution 20 - IphoneAlex McPhersonView Answer on Stackoverflow
Solution 21 - IphonepoaView Answer on Stackoverflow
Solution 22 - Iphoneuser3390994View Answer on Stackoverflow
Solution 23 - IphoneMark HenningsView Answer on Stackoverflow
Solution 24 - IphoneheikoView Answer on Stackoverflow
Solution 25 - IphoneBhushanVUView Answer on Stackoverflow