iOS:popViewController意外行为 [英] iOS: popViewController unexpected behavior

查看:363
本文介绍了iOS:popViewController意外行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上寻找解决方案。我找不到任何东西。
所以:
我正在使用UINavigationController。我正在推动两个UIViewControllers。在第二个推送的ViewController中,我正在执行此代码:

I've been searching the internet for a solution. There's nothing I could find. So: I'm using a UINavigationController. I am pushing two UIViewControllers onto it. In the second pushed ViewController i am executing this code:

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
NSLog([error localizedDescription]);
[self.navigationController popViewControllerAnimated:YES]; }

预期的事情将是最后推送的ViewController消失。在这个应用程序中,我在很少的地方这样做,它在这个非常ViewController期望无处不在。
结果是只有后退按钮离开屏幕(动画),但其他一切都停留在屏幕上。在控制台输出中,当执行此行时会打印出两件事:

The expected thing to happen would be that the last pushed ViewController disappears. In this app I am doing this on few places and it works fine everywhere expect in this very ViewController. What happens is that only the back button goes off screen (animated) but everything else stays on screen. In the Console Output two things are printed out when this line executes:


2011-03-14 16:32:44.580
TheAppXY [18518:207]嵌套pop
动画可导致
导航栏损坏

2011-03-14 16:32:44.580 TheAppXY[18518:207] nested pop animation can result in corrupted navigation bar

2011-03-14 16:32:53.507
TheAppXY [18518:207]在意外的
状态下完成
导航转换。导航栏子视图树
可能已损坏。

2011-03-14 16:32:53.507 TheAppXY[18518:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

两条错误消息我找不到任何信息。
我正在使用XCode 4和iOS SDK 4.3。也许任何人都可以帮我解决这个问题。

Two error messages I couldn't find ANY information on. I'm using XCode 4 and iOS SDK 4.3. Maybe anyone can help me with this problem.

推荐答案

我在我的代码中遇到了类似的情况并且消息说:

I came across a similar situation in my code and the message said:


嵌套推送动画可能导致导航栏损坏

nested push animation can result in corrupted navigation bar

完成导航过渡一个意外的状态。导航栏子视图树>可能会损坏。

Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree >might get corrupted.

我对这个问题的发现是我一个接一个地推动2个视图控制器快速连续,两者都是动画。

My finding to this issue was that I was pushing 2 view controllers one after the other in quick succession and both were animated.

在你的情况下,似乎你可能会一个接一个地弹出多个视图控制器。

In your case it seems that you might be popping multiple view controllers with animation one after the other.

因此,当一个视图正在进行动画时,你不应该在另一个视图上开始动画。

Hence, while one view is undergoing animation you should not start animation on another view.

我还发现如果我在一个视图上禁用动画,错误消息消失。

I also found that if I disabled animation on one view, the error message disappeared.

在我的情况下,流逻辑存在问题,因为我不打算一个接一个地推送2个视图控制器。其中一个被推入开关盒逻辑,另一个被推到结束。

In my case it was a problem with the flow logic as I did not intend to push 2 view controllers one after the other. One was being pushed within the switch case logic and another after its end.

希望这有助于某人。

这篇关于iOS:popViewController意外行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆