【问题标题】:Unbalanced calls to begin/end appearance transitions for ParentViewController对 ParentViewController 的开始/结束外观转换的不平衡调用
【发布时间】:2014-11-15 22:37:21
【问题描述】:

ParentViewController,我有

    [some_vc dismissViewControllerAnimated:YES completion:nil];
    ViewController *vc = [[ViewController alloc] initWithNibName:nil bundle:nil];
    vc.someData = data;
    [self.navigationController pushViewController:vc animated:NO];

我在日志中收到以下消息

开始/结束外观转换的不平衡调用 父视图控制器:0x7ff118750d50。

如果我将“否”改为“是”

    [self.navigationController pushViewController:vc animated:YES];

我没有看到消息。

可能是什么问题。请帮我解决这个问题。

【问题讨论】:

  • 如果在上一个事务(动画)正在进行时推送带有动画选项的新视图控制器,则会出现此问题。在推送视图控制器之前,您需要确保先前的事务已完成。 @rmaddy 回答了另一种实现方式的方法之一是将下一笔交易延迟几秒钟。

标签: ios objective-c


【解决方案1】:

这是完成处理程序的用途。试试这个:

[some_vc dismissViewControllerAnimated:YES completion:^{
    ViewController *vc = [[ViewController alloc] initWithNibName:nil bundle:nil];
    vc.someData = data;
    [self.navigationController pushViewController:vc animated:NO];
}];

这可确保在前一个控制器完成关闭之前不会显示新控制器。

另一种选择是颠倒顺序:

ViewController *vc = [[ViewController alloc] initWithNibName:nil bundle:nil];
vc.someData = data;
[self.navigationController pushViewController:vc animated:NO];
[some_vc dismissViewControllerAnimated:YES completion:nil];

这会推动新的控制器,然后关闭模式。这样做的好处是新的模式在模式被解除时可见。

【讨论】:

  • 再次非常感谢您。对于您提到的优势,“另一种选择”对我有用。谢谢
【解决方案2】:

在UITabBarController 中忘记调用viewWillAppear 的super。所以UITabBarController的过渡动画没有完成。

这导致了“开始/结束出现的不平衡呼叫”!

【讨论】:

    【解决方案3】:

    你需要添加 loadView。

    [self.navigationController pushViewController:secondViewController animated:NO];
    [self.navigationController loadView];
    

    【讨论】:

      猜你喜欢
      • 2016-01-30
      • 2016-05-28
      • 2012-01-23
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多