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];
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.
a modern solution may be this:
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:and the warning will go away.
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, Setanimated:NO
, may be solve your problemOther 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.You did not provide much context, so I assume this error is happening at startup since you are presenting a passcode view controller.
In order to get rid of this warning, I register the app delegate as a delegate of the navigation root view controller:
Then I present the modal view controller in
navigationController:didShowViewController:animated:
with adispatch_once
:Since
navigationController:didShowViewController:animated:
is called after the root view controller did appear, the Unbalanced calls to begin/end appearance transitions warning is gone.