Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0xa98e050>

While compiling the code i got

"Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0xa98e050>"

warning.

Here is my code

KVPasscodeViewController *passcodeController = [[KVPasscodeViewController alloc] init];
passcodeController.delegate = self;

UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:passcodeController];
[(UIViewController *)self.delegate presentModalViewController:passcodeNavigationController animated:YES];
like image 252
KsK Avatar asked Jan 19 '13 09:01

KsK


3 Answers

I know this is an old question, but for the sake of those who run across this again, here is what I've found.

Firstly, The question does not state where the new viewController was being called.
I suspect this was called from -(void)viewDidLoad

Move the appropriate code to -(void)viewDidAppear: and the problem should go away.

This is because at -viewDidLoad, the view has loaded, but has not yet been presented and the animations and views have not completed.

If your intent is to push a window, do it after the window has been presented and has painted.

If you ever find yourself using timers to control system behavior, ask yourself what you are doing wrong, or how you could do it more properly.

like image 50
Mark Travis Avatar answered Nov 14 '22 17:11

Mark Travis


I Found that this issue occurs if you trying to push new view controller while previous transaction (animation) in progress.

Anyway, i think, it is presentModalViewController problem, Set animated:NO, may be solve your problem

[(UIViewController *)self.delegate presentModalViewController:passcodeNavigationController animated:NO];

Other option is:

Take NSTimer and call above code between may be 0.50 to 1 second. This also helpful trick. so your pervious viewController has done its animation.

like image 36
iPatel Avatar answered Nov 14 '22 17:11

iPatel


This warning appears when you try to load a new viewController before a previously included one is done animating. If your intention is to do that, simply add your code to a dispatch_async(dispatch_get_main_queue() block:

dispatch_async(dispatch_get_main_queue(), ^(void){
        [(UIViewController *)self.delegate presentModalViewController:passcodeNavigationController animated:YES];
});

and the warning will go away.

like image 11
Paula Vasconcelos Gueiros Avatar answered Nov 14 '22 18:11

Paula Vasconcelos Gueiros