【问题标题】:Exc_Bad_Access in alertview show警报视图中的 Exc_Bad_Access 显示
【发布时间】:2013-07-24 19:23:13
【问题描述】:

在 UIAlertView 显示消息中获取 Exc_Bad_Access。

UIAlertView *systemAlert1 = [[UIAlertView alloc]initWithTitle:@"System message" message:@"note" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [systemAlert1 show];  **//Crashing on this line [EXC_BAD_ACCESS]**
    [systemAlert1 release]; 

为什么我会得到这个?请帮忙

【问题讨论】:

  • 开启僵尸模式后检查。
  • 您的代码似乎没问题。问题一定出在其他地方。你在哪里显示你的警报?是后台线程吗?
  • 它在模拟器上运行正常,但在设备上崩溃。
  • 僵尸启用但它正在抛出 exc_bad_access
  • 需要更多代码才能看到整个图片

标签: iphone objective-c xcode crash exc-bad-access


【解决方案1】:

任何 UI 内容(包括显示警报)都应在主线程上完成。 如果您在其他线程上执行此操作,它肯定会崩溃。

【讨论】:

    【解决方案2】:

    这可能是因为您的警报是从后台线程而不是主线程调用的。建议只在主线程上进行用户界面相关的更改,以避免应用程序的这种行为

    试试这个代码:

    UIAlertView *systemAlert1 = [[UIAlertView alloc]initWithTitle:@"System message" message:@"note" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [systemAlert1 performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES]; 
    [systemAlert1 release]; 
    

    希望这会有所帮助。如果您还需要什么,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-24
      • 2019-05-30
      相关资源
      最近更新 更多