【问题标题】:cocos2d mac project alert window is below main window under full screen modecocos2d mac 项目警告窗口在全屏模式下主窗口下方
【发布时间】:2012-12-10 04:50:20
【问题描述】:

我在我的 mac 游戏中使用 cocos2d。在全屏模式下,警报窗口位于主窗口下方,无法点击。这是我的代码:

NSAlert* alert = [[NSAlert alloc] init];
alert.alertStyle = NSWarningAlertStyle;
[alert addButtonWithTitle:[Helper getLocalizedStringWithString:@"ok"]];
alert.messageText = [Helper getLocalizedStringWithString:@"you need to play through classic game and expert mode"];

switch ([alert runModal]) {
    case NSAlertFirstButtonReturn:
        break;

    default:
        break;
}    

[alert release];

我尝试将[alert window]s zOrder 设置为 MaxInteger,但仍未显示在顶部。

这里有什么问题吗?

【问题讨论】:

    标签: objective-c macos cocos2d-iphone fullscreen


    【解决方案1】:

    我会用这个 NSAlert 的方法来展示它:

    - (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)modalDelegate  
        didEndSelector:(SEL)alertDidEndSelector contextInfo:(void *)contextInfo;
    

    所以你肯定会看到它,因为它附在窗户上。

    编辑

    如果您仍想将其作为单独的面板,请尝试以下操作:

    [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
    [alert runModal];
    

    【讨论】:

    • 其实我还是更喜欢分离窗口的方法。无论如何,表单模式还不错
    • 也许您仍然可以使用单独的面板运行它并将其放在顶部。试试我在编辑中添加的代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-06
    • 2014-08-16
    • 1970-01-01
    • 1970-01-01
    • 2012-06-24
    • 2012-05-02
    相关资源
    最近更新 更多