iOS6中UIAlertView上的EXC_BAD_ACCESS代码2 [英] EXC_BAD_ACCESS code 2 on UIAlertView in iOS6

查看:109
本文介绍了iOS6中UIAlertView上的EXC_BAD_ACCESS代码2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图找出为什么我在我的应用程序中发生此崩溃。

I'm trying to figure out why im getting this crash in my app.

在使用ios5.1的模拟器中运行的Xcode 4.4中,它完全正常,但当我切换到xcode 4.5和ios6时,我得到一个EXC_BAD_ACCESS代码2.这是我的代码:

It works perfectly fine in Xcode 4.4 running in the simulator with ios5.1, but when i switch into xcode 4.5 and ios6 I'm getting an EXC_BAD_ACCESS code 2. Here is my code:

- (void) myMethod
{
    UIAlertView *alertview = [[[UIAlertView alloc]initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] autorelease];
    alertview.tag = 1
    [alertview show];
}

这是给我一个上的EXC_BAD_ACCESS代码2 [UIAlertView show] line

this is giving me an EXC_BAD_ACCESS code 2 on the [UIAlertView show] line

任何想法?

谢谢!

推荐答案

我知道了。
我有同样的问题,在我的情况下,似乎该方法现在从后台抛出(现在在ios7中,在ios6中,UIAlertView被自动放入主线程,因为@nodepond说-thanks! - )..

I've got it. I have the same problem, in my case it seems that the method is thrown from background now (now in ios7, in ios6 UIAlertView was automatically put into the main-thread as @nodepond says -thanks!-)..

尝试确保从主线程显示该方法:

try to assure that the method is shown from main thread:

[alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];

祝你好运!

这篇关于iOS6中UIAlertView上的EXC_BAD_ACCESS代码2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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