我可以禁用自定义键盘(iOS8)为我的应用程序?

编辑:tl;博士 – 这是可能的,见下面接受的答案。

有没有(不仅是程序)的方式来防止我的应用程序使用自定义键盘(iOS8)? 我主要感兴趣的是“每应用程序”设置,所以只是我的应用程序不允许使用自定义键盘,但禁用系统范围内的自定义键盘是最后的手段。

到目前为止,我知道自定义键盘是系统范围的,可以被任何应用程序使用。 操作系统将回secureTextEntry股票键盘仅用于安全文本input(文本字段secureTextEntry设置为YES )。 这里没有多less希望。

我从App Extension Programming Guide中得到了一个印象,MDM(移动设备pipe理)可以限制设备使用自定义键盘,但是在OS X Yosemite的Apple Configurator.app的新testing版本中没有find这个选项。 “configuration器”只是缺less这个选项?

这里有什么想法? 我应该提出一个雷达,build议苹果应该引入这样的function?

看起来你得到了你想要的beta种子3. UIApplication.h 440行:

 // Applications may reject specific types of extensions based on the extension point identifier. // Constants representing common extension point identifiers are provided further down. // If unimplemented, the default behavior is to allow the extension point identifier. - (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier NS_AVAILABLE_IOS(8_0); 

它目前不包含在文档中,但听起来像它会做到你在这里问的。

我猜这些“扩展点标识符”不是扩展名的唯一标识符,而是它们的types,因为在545行也有这样的标识符:

 // Extension point identifier constants UIKIT_EXTERN NSString *const UIApplicationKeyboardExtensionPointIdentifier NS_AVAILABLE_IOS(8_0); 

TLDR:要禁用自定义键盘,您应该在应用程序委托中包含如下内容:

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

Swift 3:

 func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplicationExtensionPointIdentifier) -> Bool { if extensionPointIdentifier == UIApplicationExtensionPointIdentifier.keyboard { return false } return true } 

我只是想为那些想在Xamarin iOS中实现这个方法的开发者添加这个。 这个想法是重写AppDelegateShouldAllowExtensionPointIdentifier方法:

 public override bool ShouldAllowExtensionPointIdentifier(UIApplication application, NSString extensionPointIdentifier) { if (extensionPointIdentifier == UIExtensionPointIdentifier.Keyboard) { return false; } return true; }