“[UIAlertView show]”立即返回,不显示消息弹出窗口

时间:2014-03-29 00:01:23

标签: ios objective-c cocoa-touch cocos2d-iphone uialertview

我试图为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 (;;) { }
}

然而," [警示显示]"在没有显示弹出对话框的情况下立即返回。 我需要在当前应用程序屏幕的顶部显示对话框并阻止调用线程,直到用户单击其中一个按钮。应用程序将在函数返回后终止。

该应用程序正在运行Cocos2d,因此可能Cocos绘图干扰了UIAlertView ......但我对iOS编程很新,可能会遗漏一些明显的东西。

注意:我没有在实际设备上测试过这个,只在模拟器中测试过。它可能是模拟器的限制/错误吗?

1 个答案:

答案 0 :(得分:1)

看起来您必须向cocos2d寻求帮助才能获得alertview的正确父级 这篇较老的帖子提出了一个大纲 http://www.cocos2d-iphone.org/forums/topic/how-to-popup-a-uialertview-with-cocos2d/

相关问题