与 Safari 非常相似,尝试实现一个按钮,单击该按钮会打开“系统偏好设置”>“扩展”>“共享菜单”窗格。
我努力了:
NSURL *URL = [NSURL URLWithString:@"x-apple.systempreferences:com.apple.preferences.extensions?Share_Menu"];
[[NSWorkspace sharedWorkspace] openURL:URL];
然而,这似乎不适用于新版本,有什么想法吗?
您可以使用 Scripting Bridge 执行以下操作:
SBSystemPreferencesApplication *systemPrefs =
[SBApplication applicationWithBundleIdentifier:@"com.apple.systempreferences"];
[systemPrefs activate];
SBElementArray *panes = [systemPrefs panes];
SBSystemPreferencesPane *notificationsPane = nil;
for (SBSystemPreferencesPane *pane in panes) {
if ([[pane id] isEqualToString:@"com.apple.preferences.extensions"]) {
notificationsPane = pane;
break;
}
}
[systemPrefs setCurrentPane:notificationsPane];
SBElementArray *anchors = [notificationsPane anchors];
for (SBSystemPreferencesAnchor *anchor in anchors) {
if ([anchor.name isEqualToString:@"Extensions"]) {
[anchor reveal];
}
}
当然,您需要将 ScriptingBridge 框架添加到您的项目中,并为系统首选项添加 Scripting Bridge 头文件。有关如何使用 Scripting Bridge 的更多详细信息,您可以在 Apple 的开发人员文档中找到。
希望这可以帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)