我正在尝试为 iOS 实现错误弹出功能。我当前的实现:
void SysErrorAlert(NSString * title, NSString * message, ...)
{
NSString * contents = nil;
va_list args;
va_start(args, message);
contents = [[NSString alloc] initWithFormat:message arguments:args];
va_end(args);
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:title
message:contents
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[alert show];
// tried this but popup still never shows...
//for (;;) { }
}
但是,“[alert show]”会立即返回,而不会显示弹出对话框。 我需要将对话框显示在当前应用程序屏幕的顶部并阻止调用线程,直到用户单击其中一个按钮。应用程序将在函数返回后终止。
该应用程序正在运行 Cocos2d,所以 Cocos 绘图可能会干扰 UIAlertView...但我对 iOS 编程还很陌生,可能在这里遗漏了一些明显的东西。
注意:我没有在实际设备上测试过这个,只在模拟器上测试过。这可能是模拟器的限制/错误吗?
最佳答案
看起来你必须向 cocos2d 寻求帮助才能为警报 View 找到正确的父级 这篇较旧的文章提出了一个大纲: http://www.cocos2d-iphone.org/forums/topic/how-to-popup-a-uialertview-with-cocos2d/
关于ios - "[UIAlertView show]"不显示消息弹窗立即返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22725232/