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

问题描述 投票:6回答:5

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

此代码在iOS 10中不起作用

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

并添加了URL Scheme

ios ios10 custom-keyboard ios-extensions
5个回答
5
投票

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


2
投票

适用于iOS 10+

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

关键点:

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


0
投票

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


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;
    }
}

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];
     }
 }
© www.soinside.com 2019 - 2024. All rights reserved.