我想弄清楚为什么我的应用程序会崩溃。
它在带有 ios5.1 的模拟器中运行的 Xcode 4.4 中运行良好,但是当我切换到 xcode 4.5 和 ios6 时,我得到了 EXC_BAD_ACCESS 代码 2。这是我的代码:
- (void) myMethod
{
UIAlertView *alertview = [[[UIAlertView alloc]initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] autorelease];
alertview.tag = 1
[alertview show];
}
这在
[UIAlertView show]
上给了我一个 EXC_BAD_ACCESS 代码 2线有任何想法吗?
谢谢!
最佳答案
我懂了。
我有同样的问题,在我的情况下,现在似乎该方法是从后台抛出的(现在在 ios7 中,在 ios6 中 UIAlertView 自动放入主线程,因为@nodepond 说-谢谢!-)。
尝试确保从主线程显示该方法:
[alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
祝你好运!
关于uialertview - iOS6 中 UIAlertView 上的 EXC_BAD_ACCESS 代码 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12468677/