ios <FirstViewController: 0x2a2c00> 开始/结束外观转换的不平衡调用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6809593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:51:28  来源:igfitidea点击:

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

iphoneiostransition

提问by C.Johns

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?

我在模拟我的应用程序时遇到了这个问题,它不是错误或警告,但它出现在我的控制台中,有没有人遇到过这种情况?

采纳答案by chings228

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

就我而言,当您非常快速地单击 tableview 中的两个选项卡时,会发生此错误。

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.

结果导致titlename错误,后退按钮消失。有人提到,当你推送一个视图时,set animated:NO. 错误会消失,但仍会导致一些奇怪的行为。它推送两个视图,然后您需要返回两次才能返回 tableview 屏幕。

Method I tried in order to resolve this problem:

为了解决这个问题,我尝试过的方法:

add BOOL cellSelected;

添加 BOOL cellSelected;

in viewWillAppearcellSelected = YES;

viewWillAppearcellSelected = YES;

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

在 didselectcell 委托中 if (cellSelected){cellSelected = NO; do action ; }

This helps prevent clicking two different cells very fast.

这有助于防止非常快速地单击两个不同的单元格。

回答by tttthomasssss

In my case it happened when I triggered [self performSegueWithIdentifier:@"SomeIdentifier" sender:self];within a UINavigationControlleritem's viewDidLoadmethod.

在我的情况下,它发生在我[self performSegueWithIdentifier:@"SomeIdentifier" sender:self];UINavigationController项目的viewDidLoad方法中触发时 。

Moving it into the viewDidAppearmethod solved the problem.

将其移动到viewDidAppear方法中解决了问题。

The reason very likely is that in viewDidLoadnot all of the fancy animations have already been finished, whereas in viewDidAppeareverything's done.

原因很可能是,viewDidLoad并不是所有的花哨动画都已经完成了,而viewDidAppear一切都已经完成了。

回答by Igor_CodabraSoft

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

我也有这个问题。我找到了解决这个问题的两种方法:

  1. You can see this solution above.
  2. I found subclass from UINavigationControllerwhere this problem resolved. Buffered Navigation Controller
  1. 您可以在上面看到此解决方案。
  2. 我从UINavigationController解决这个问题的地方找到了子类。缓冲导航控制器

回答by prohuutuan

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

回答by kunalg

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

我在同一个问题上遇到了很多问题。我通过这种方式解决了这个问题

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

1)您没有使用UIViewController's指定的初始化程序initWithNibName:bundle:。尝试使用它而不仅仅是init.

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

2)设置animated:YES为NO,就解决了问题。例如。[self.navigationController pushViewController: viewController_Obj animated:NO];

回答by dimanitm

I had the same issue using navigation controller and push other controllers to it. I tried to use Buffered Navigation Controllerand 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.

我在使用导航控制器并将其他控制器推送到它时遇到了同样的问题。我尝试使用缓冲导航控制器和其他几种方法,但它对我不起作用。在花了一些时间弄清楚之后,我注意到如果您在上一个事务(动画)正在进行时尝试推送新的视图控制器(我猜持续时间约为 0.5 秒),则会出现此问题。无论如何,我通过委派导航控制器并等待以前的动画完成来快速解决。

回答by Nikolay Shubenkov

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:

确保您不要忘记在 -viewWillAppear、-viewDidAppear、-viewDidLoad、-viewWillDisappear、-viewDidDisappear 中在这些方法的重载中调用正确的超级方法。例如,在我的情况下,我不匹配的方法名称是这样的:

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

notice that appearand disappearmethods are mismatched

请注意,出现消失的方法不匹配

回答by infiniteLoop

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

说动画在最后一个相关动画未完成之前开始。那么,在推送新的视图控制器之前,您是否弹出任何视图控制器?或者可能会弹出到 root ?如果是,请尝试在没有动画的情况下这样做[self.navigationController popToRootViewControllerAnimated:NO];

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

看看这是否解决了问题,在我的情况下,这解决了问题。

回答by Mehul Thakkar

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

消息原因:当且仅当您从当前视图控制器的、或方法推送/呈现另一个视图控制器时viewWillAppear,才会显示此消息loadViewinitviewDidLoad

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

删除错误消息的方法:将您的推送/呈现代码移动到viewDidAppear方法将解决问题

回答by balooka

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.

我遇到这个问题是因为我从没有 UITabbar 的 viewController 调用 UIPrintInteractionController,也没有 UINavigationBar。似乎 UIPrintInteractionController 没有得到正确的 printInteractionControllerParentViewController。在委托中实现该方法并返回当前为我工作的 rootViewController。

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