ios-是否应在NSUrlConnection的返回块中使用UIAlertView?
当我在NSUrlConnection的返回块中使用UIAlertView时,会发生一些罕见的崩溃。我不允许像这样在异步线程中使用UIAlertView吗ios-是否应在NSUrlConnection的返回块中使用UIAlertView?,ios,ios5,nsurlconnection,uialertview,Ios,Ios5,Nsurlconnection,Uialertview,当我在NSUrlConnection的返回块中使用UIAlertView时,会发生一些罕见的崩溃。我不允许像这样在异步线程中使用UIAlertView吗 大多数情况下,它似乎工作正常。我认为您只能在主线程上使用UIAlertView。 在返回块中使用performSelectorOnMainThread:withObject:waitUntilDone:。我认为您只能在主线程上使用UIAlertView。 在返回块中使用performSelectorOnMainThread:withObject
大多数情况下,它似乎工作正常。我认为您只能在主线程上使用UIAlertView。
在返回块中使用performSelectorOnMainThread:withObject:waitUntilDone:。我认为您只能在主线程上使用UIAlertView。
在返回块中使用performSelectorOnMainThread:withObject:waitUntilDone:。所有与UI相关的代码都需要在主线程上运行 当我在另一个线程上显示alertView时,我遇到了类似的崩溃 您需要使用dispatch_async或performSelectorOnMainThread显示alertView 或
所有与UI相关的代码都需要在主线程上工作 当我在另一个线程上显示alertView时,我遇到了类似的崩溃 您需要使用dispatch_async或performSelectorOnMainThread显示alertView 或
@rmaddy谢谢,我正试图向用户发送警报消息。我可以使用什么替代UIAlertView?@rmaddy感谢我试图向用户发送警报消息。我可以使用什么替代UIAlertView?
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
});
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntillDone:NO];