【问题标题】:Programmatically detect all keyboards which are set in my iPhone settings?以编程方式检测在我的 iPhone 设置中设置的所有键盘?
【发布时间】:2016-11-27 18:40:19
【问题描述】:

我怎么知道在我的 iPhone 键盘设置中启用了多少键盘。

即使用户从应用商店下载了其他自定义键盘,我仍然希望以编程方式出现在列表中。

【问题讨论】:

    标签: ios objective-c swift2 custom-keyboard


    【解决方案1】:
    NSArray *keyboards = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] objectForKey:@"AppleKeyboards"]; // Array of all active keyboards
    
    NSLog(@"List of all keyboards : %@",keyboards);
    

    【讨论】:

    • 似乎不适用于 ios8 sim...(未在 ios8 设备上检查),但适用于 >=9 sim/device。
    【解决方案2】:

    您可以询问当前的第一响应者(UITextField、UISearchBar 等)。

    // 假设您有指向当前输入的搜索栏的实例变量

    UITextInputMode *inputMode = [self.searchBar textInputMode];
    NSString *lang = inputMode.primaryLanguage;
    

    【讨论】:

      猜你喜欢
      • 2011-08-26
      • 1970-01-01
      • 2011-04-06
      • 2012-01-29
      • 2018-01-17
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      相关资源
      最近更新 更多