我正在使用 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/