Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c '中的警报窗口;代理申请';未给予关注_Objective C_Xcode_Macos_Cocoa_Alert - Fatal编程技术网

Objective c '中的警报窗口;代理申请';未给予关注

Objective c '中的警报窗口;代理申请';未给予关注,objective-c,xcode,macos,cocoa,alert,Objective C,Xcode,Macos,Cocoa,Alert,更新:我的应用程序正在以代理身份运行,我发现当我关闭它时,警报窗口会正常聚焦。有没有办法解决这个问题 第一次在AppController的awakeFromNib中运行应用程序时,我会显示一个警报窗口。当我在Xcode中运行它时,它是作为一个关键窗口运行的,但是当我构建应用程序时,它没有被赋予焦点。为什么?我怎样才能让它聚焦 AppController.m NSInteger kbSetup = NSRunAlertPanel(kbLetsStart, kbLetsStartDscr, @"OK

更新:我的应用程序正在以代理身份运行,我发现当我关闭它时,警报窗口会正常聚焦。有没有办法解决这个问题

第一次在AppController的awakeFromNib中运行应用程序时,我会显示一个警报窗口。当我在Xcode中运行它时,它是作为一个关键窗口运行的,但是当我构建应用程序时,它没有被赋予焦点。为什么?我怎样才能让它聚焦

AppController.m

NSInteger kbSetup = NSRunAlertPanel(kbLetsStart, kbLetsStartDscr, @"OK", @"Maybe Later", nil);
kbSetup == 1 ? [self showPreferencesPanel:nil] : [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0];

即使我创建一个NSAlert实例,然后执行
[[alert window]MakeKeyandDerfront:self]
,它仍然不是键…

好的,解决方案是调用
[NSApp activateIgnoringOtherApps:YES]打开警报之前。doh