macos – 调用TransformProcessType()时,应用程序菜单不会显示

macos – 调用TransformProcessType()时,应用程序菜单不会显示,第1张

概述如果你像这样调用TransformProcessType(): ProcessSerialNumber psn = { 0, kCurrentProcess }; (void) TransformProcessType(&psn, kProcessTransformToForegroundApplication); 然后cocoa应用程序菜单显示,除非你在应用程序中尽早调用它(例如在appli 如果你像这样调用transformProcesstype():

ProcessSerialNumber psn = { 0,kCurrentProcess }; (voID) transformProcesstype(&psn,kProcesstransformToForegroundApplication);

然后cocoa应用程序菜单不显示,除非你在应用程序中尽早调用它(例如在applicationWillFinishLaunching中).

解决方法 我向Apple寻求帮助,他们帮助我很好. Quote:

The reason why the menu bar isn’t show when you call transformProcesstype is that your app is already the active app (that is,[[NSRunningApplication currentApplication] isActive] returns YES) and the menu bar for an app is shown when the app is activated

这是他们的解决方法:

- (voID)transformStep1 {    for (NSRunningApplication * app in [NSRunningApplication runningApplicationsWithBundleIDentifIEr:@"com.apple.finder"]) {        [app activateWithOptions:NSApplicationActivateIgnoringOtherApps];        break;    }    [self performSelector:@selector(transformStep2) withObject:nil afterDelay:0.1];}- (voID)transformStep2{    ProcessSerialNumber psn = { 0,kCurrentProcess };     (voID) transformProcesstype(&psn,kProcesstransformToForegroundApplication);    [self performSelector:@selector(transformStep3) withObject:nil afterDelay:0.1];}- (voID)transformStep3{    [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];}
总结

以上是内存溢出为你收集整理的macos – 调用TransformProcessType()时,应用程序菜单不会显示全部内容,希望文章能够帮你解决macos – 调用TransformProcessType()时,应用程序菜单不会显示所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1013782.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存