objective-c - cocos2d mac项目全屏模式下警报窗口位于主窗口下方

标签 objective-c macos cocos2d-iphone fullscreen

我正在使用 cocos2d 来玩我的 Mac 游戏。在全屏模式下,警报窗口位于主窗口下方,因此不可点击。这是我的代码:

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];

我尝试将[警报窗口]的 zOrder 设置为 MaxInteger,但仍然没有显示在顶部。

这里有什么问题吗?

最佳答案

我会使用这个 NSAlert 的方法来呈现它:

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

所以你一定会看到它,因为它附着在 window 上。

编辑

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

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

关于objective-c - cocos2d mac项目全屏模式下警报窗口位于主窗口下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14009924/

相关文章:

c++ - 如何在 Qt C++ 中生成带数字签名的 PDF

objective-c - AVFoundation 捕获 UIImage

linux - Git 中的多平台开发和 autocrlf 选项

objective-c - 自定义 NSTextField 中的 TAB 不会将焦点放在另一个控件上

cocos2d-iphone - cocos2d 隐藏/显示带有动画的 Sprite

cocos2d-iphone - Cocos2d 如何让一个 Sprite 跟随另一个 Sprite ?

ios - Cocos2d 中的无限水平滚动

ios - Xcode:无法检查应用程序包

ios - 如何使用 ARC 模式保持单个对象?

ios - 通过在 ios sdk 中添加行来格式化 UITextView 的目的