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

查看:28
本文介绍了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.580TheAppXY[18518:207] 嵌套弹出动画可能导致损坏导航栏

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.507TheAppXY[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 个视图控制器.一个在 switch case 逻辑中被推动,另一个在其结束后被推动.

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.

希望这对某人有所帮助.

Hope this helps someone.

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

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