如何在iOS 10中以编程方式打开键盘的设置屏幕?

时间:2016-09-09 18:28:48

标签: ios ios10 custom-keyboard ios-extensions

如何在iOS 10中以编程方式打开键盘的设置屏幕?

此代码在iOS 10中无效

NSURL *keyboardSettingsURL = [NSURL URLWithString: @"prefs:root=General&path=Keyboard/KEYBOARDS"];
    [[UIApplication sharedApplication] openURL:keyboardSettingsURL];

并添加了URL Scheme

5 个答案:

答案 0 :(得分:5)

看起来iOS 10已禁用此功能。我相信https://developer.apple.com/library/content/qa/qa1924/_index.html不再有效。我检查了几个顶级键盘应用程序,它们已更新为不再具有指向首选项的直接链接,或者具有非工作按钮。

答案 1 :(得分:2)

适用于iOS 10 +

NSURL *keboardURL = [NSURL URLWithString: @"App-Prefs:root=General&path=Keyboard/KEYBOARDS"];
[[UIApplication sharedApplication] openURL:keyboardURL];

关键点:

@ “的App-偏好设置:根=通用及安培;路径=键盘/键盘”

答案 2 :(得分:0)

如果您尚未添加URL方案,则可能需要将其添加到项目中。可以在Apple Q&A Reference找到说明和更多详细信息。希望这有帮助!

答案 3 :(得分:0)

在iOS 10中,需要一个新的URL。尝试使用此代码测试两个网址:

NSArray* urlStrings = @[@"prefs:root=General&path=Keyboard/KEYBOARDS", @"App-Prefs:root=General&path=Keyboard/KEYBOARDS"];
for(NSString* urlString in urlStrings){
    NSURL* url = [NSURL URLWithString:urlString];
    if([[UIApplication sharedApplication] canOpenURL:url]){
        [[UIApplication sharedApplication] openURL:url];
        break;
    }
}

答案 4 :(得分:0)

For IOS-10 or higher,openURL is deprecated. use with completion handler like below.

NSString *settingsUrl= @"App-Prefs:root=General&path=Keyboard";
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0){
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:settingsUrl]]) {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:settingsUrl] options:@{} completionHandler:nil];
     }
 }
相关问题