2012-11-01 79 views
8

我在[alert show]行中获取了EXC_BAD_ACCESS。UIAlertview代码上的EXC_BAD_ACCESS = 1

为什么我得到这个?

alert = [[UIAlertView alloc]initWithTitle:@"Application Alert" message:@"all date popup" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Update",nil]; 

[alert show]; //EXC_BAD_ACCESS on this line 
+1

退房这里给出我的答案[http://stackoverflow.com/a/13084383/1538079] –

+1

你打电话它来自主线程? –

+0

'alert'的原型是什么.. – AppleDelegate

回答

6

只是要代表零,不适用自行委托.CODE像下面

alert = [[UIAlertView alloc]initWithTitle:@"Application Alert" message:@"all date popup" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Update",nil]; 

[alert show]; 

如果您使用的是代表自己,那么你将不得不使用警报的委托方法

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 

那么它不会给EXC_Bad_Excess.let我知道,如果它的工作原理.. !!!!快乐编码....

16

这个崩溃必须在iOS 6.此崩溃解决方法如下:

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

+3

如果因为从后台调用''alert show''而错误,这是正确的解决方案。 – Hlung

+0

非常感谢! – alexmorhun

相关问题