UINavigationController popViewControllerAnimated:在iOS 6中崩溃 [英] UINavigationController popViewControllerAnimated: crash in iOS 6
问题描述
以下代码在iOS 4和5中运行良好,但在iOS 6中使用 EXC_BAD_ACCESS
崩溃。我很感激任何排除它的帮助。此代码在 UITableViewController
中调用,用于处理我的应用程序的搜索逻辑:
The code below works fine in iOS 4 and 5 but crashes in iOS 6 with EXC_BAD_ACCESS
. I'd appreciate any help in troubleshooting it. This code is being called in a UITableViewController
that handles my app's search logic:
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
transition.type = kCATransitionFade;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];
我添加 tableView
的方式类似并且在被叫时不会崩溃:
The way I add the tableView
is similar and doesn't crash when called:
SearchTVC *searchTable = [[SearchTVC alloc] init];
searchTable.detailViewController = self.detailViewController;
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
transition.type = kCATransitionFade;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:searchTable animated:NO];
可能是什么问题?
* 编辑
有趣的是,如果我使用 [self.navigationController popViewControllerAnimated:YES],则不会发生崩溃;
( YES
而不是否
)。但当然这会破坏使用自定义流行动画的目的。
Interestingly the crash doesn't occur if I use [self.navigationController popViewControllerAnimated:YES];
(YES
rather than NO
). But of course this defeats the purpose of using a custom pop animation.
推荐答案
我知道我的问题很模糊,但我没有太多其他事情要做。我知道行 [self.navigationController popViewControllerAnimated:NO];
是问题,但我无法弄清楚原因。然后我遇到了这个问题,第一个答案建议我将我的搜索表作为一个实例变量,而不是每次我想呈现它时创建一个新的,并且实际上有效。它一定是一个内存问题我无法解决。
I know my question was vague, but I didn't have much else to go off of. I knew the line [self.navigationController popViewControllerAnimated:NO];
was the problem but I couldn't figure out why. Then I came across this question and the first answer suggested I make my search table an instance variable rather than creating a new one every time I want to present it, and that actually worked. It must be a memory issue that I can't wrap my head around.
tl; dr :
tl;dr :
确保推送和弹出的 UIViewController
是一个实例变量。
Make sure the UIViewController
that's being pushed and popped is an instance variable.
这篇关于UINavigationController popViewControllerAnimated:在iOS 6中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!