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?
问题:
回答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.
回答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.
回答3:
I have this problem too. I found two solutions to this problem:
- You can see this solution above.
- I found subclass from
UINavigationController
where this problem resolved. Buffered Navigation Controller
回答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];
});
回答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];
回答6:
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.
回答7:
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
回答8:
'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.
回答9:
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
回答10:
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)
}
}
}
回答11:
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.
回答12:
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
回答13:
I also got this at
[self dismissModalViewControllerAnimated:YES];
I changed the YES
to a NO
, and that solved the problem.
回答14:
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
回答15:
For what it's worth, I got this same error when not including a call to [super viewDidLoad:animated]
in my viewDidLoad
override.
回答16:
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:
回答17:
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.
回答18:
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;
回答19:
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:
回答20:
the reason behind the error " Unbalanced calls to begin/end appearance transitions" is when you navigate | segue twice at the same time
回答21:
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];
回答22:
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.
回答23:
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.
回答24:
In my case I was fetching NSData
from NSURL
inside 'viewDidLoad
' method.
回答25:
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)
}