Make a NSAlert the topmost window?
我已在我的应用程序中创建了主窗口以进行以下设置:
1
2 3 4 5 |
[self setLevel:kCGDesktopWindowLevel + 1];
[self setCollectionBehavior: (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | NSWindowCollectionBehaviorIgnoresCycle)]; |
这是一个非常自定义的窗口,有点浮在桌面上方。
此外,它是一个菜单栏应用程序 (LSUIElement)。
好的,所以如果出现问题,我需要显示警报。这是我的做法:
1
2 3 4 5 6 |
NSAlert *alert = [NSAlert alertWithMessageText:@“”
defaultButton:@“” alternateButton:@“” otherButton:@“” informativeTextWithFormat:@“”]; [alert runModal]; |
当然我已经填写了按钮和其他文本。
这是我的问题:当我的应用程序当前不是关键应用程序,并且弹出此警报时,它不是关键窗口。像这样:
来源:https://www.codenong.com/5269116/