【问题标题】:How to detect which custom keyboard (ios 8) is currently in use for text entering如何检测当前正在使用哪个自定义键盘(ios 8)进行文本输入
【发布时间】:2015-02-11 23:39:19
【问题描述】:

我正在使用此解决方案 (https://stackoverflow.com/a/25786928) 来检测在 Settins 应用程序 (iOS 8) 中激活的所有自定义键盘:

- (void)printoutAllActiveKeyboards {
   // Array of all active keyboards
   NSArray *keyboards = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] objectForKey:@"AppleKeyboards"]; 
   for (NSString *keyboard in keyboards)
      NSLog(@"Custom keyboard: %@", keyboard);
}

但这对我的项目来说还不够——我需要知道用户当前选择了哪个自定义键盘来输入文本。我研究了 stackoverflow 和其他资源,但没有找到任何解决方案。有什么方法可以在我的应用中检测当前选择了哪个自定义键盘进行文本输入?

谢谢!

【问题讨论】:

  • 不确定这个问题今天是否仍然与您相关,但对于遇到此问题的其他人,这里有一个在 2018 年仍然有效的解决方案:stackoverflow.com/a/26368224/7349426

标签: ios objective-c ios8 ios-app-extension custom-keyboard


【解决方案1】:

看看这个UIApplication API 方法来禁用自定义键盘:

- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier {
    if ([extensionPointIdentifier isEqualToString: UIApplicationKeyboardExtensionPointIdentifier]) {
         return NO;
    }
    return YES;
}

也许您可以修改UIApplicationKeyboardExtensionPointIdentifier 的值以满足您的需求

【讨论】:

  • 问题是关于如何知道当前选择了哪个自定义键盘。不禁用自定义键盘。此 API 仅有助于禁用自定义键盘。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-24
  • 2014-08-11
  • 2017-11-23
  • 1970-01-01
  • 2015-06-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多