我正在使用警报表来显示警报消息。我将警报表放在主线程中,并且我使用了更多这样的警报表,但是在运行应用程序时会出现警报消息。
但有时当用户单击警报消息中的确定按钮时。警报消息没有消失,我无能为力。我唯一能做的就是杀死应用程序并重新启动它。
我检查了日志文件以发现问题。但我无法从日志文件中获取问题,而且一切正常,日志文件中没有崩溃。我检查了更多参考资料,但找不到问题出在哪里。这是示例代码。
dispatch_async(dispatch_get_main_queue(), ^{
NSAlert *alertView2 = [NSAlert alertWithMessageText:@"Server error occured. please check the internet connectivity" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@""];
[[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
int response;
[alertView2 beginSheetModalForWindow:self.window
modalDelegate:self
didEndSelector:@selector(alertDidEndDoNothing:returnCode:contextInfo:)
contextInfo:&response];
});
问题是由于线程。这意味着同时调用了两个方法,或者问题在警报表中。