本文介绍了如何打开“共享菜单" OSX上的偏好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
与Safari一样,尝试实现一个按钮,该按钮在单击时会打开系统偏好设置">扩展">共享菜单"窗格.
Much like Safari, trying to implement a button that when clicked opens System Preferences > Extensions > Share Menu pane.
我尝试过:
NSURL *URL = [NSURL URLWithString:@"x-apple.systempreferences:com.apple.preferences.extensions?Share_Menu"];
[[NSWorkspace sharedWorkspace] openURL:URL];
但是在新版本上似乎不起作用,有什么主意吗?
However it seems like that is not working on newer versions, any ideas?
推荐答案
您可以使用脚本桥来执行以下操作:
You can use Scripting Bridge to do something like this:
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头文件以获取系统首选项.您可以在Apple的开发人员文档中找到有关如何使用Scripting Bridge的更多详细信息.
Of course you need to add the ScriptingBridge framework to your project and a Scripting Bridge header file for system preferences. More details on how to use Scripting Bridge you can find in the developer documentation from Apple.
希望这会有所帮助
这篇关于如何打开“共享菜单" OSX上的偏好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!