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

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

我在日志中看到以下信息:

未平衡的调用begin/end appearance transitions,针对 ParentViewController:0x7ff118750d50。

如果我将“NO”更改为“YES”

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

我看不到这条消息。

可能存在什么问题,请帮助我解决。


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

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

这将推送新的控制器,然后关闭模态框。这样做的好处是,当模态框关闭时,新的控制器是可见的。


非常感谢您。对于您提到的优点,“另一个选项”对我很有帮助。谢谢。 - GJain

0
在UITabBarController中忘记调用viewWillAppear的super方法。因此,UITabBarController的转换动画没有完成。
这导致了“不平衡的开始/结束出现”!

-1

你需要添加loadView。

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接