编辑:tl; dr-有可能,请参见下面的可接受答案。

有什么(不仅是程序性的)方法可以防止自定义键盘(iOS8)用于我的应用程序?我主要对“每个应用程序”设置感兴趣,因此不允许我的应用程序使用自定义键盘,但是在系统范围内禁用自定义键盘是最后的选择。

到目前为止,我知道自定义键盘是系统范围的,并且可以被任何应用程序使用。操作系统将仅退回备用键盘,仅用于安全文本输入(secureTextEntry设置为YES的文本字段)。这里希望不大。
App Extension Programming Guide给我的印象是,MDM(移动设备管理)可以完全限制设备使用自定义键盘,但是在OS X Yosemite的新beta版Apple Configurator.app中我没有找到该选项。 “配置器”只是缺少该选项吗?

这里有什么想法吗?我是否应该提出雷达建议苹果应该引入这种功能?

最佳答案

看起来您已经在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);

它目前未包含在文档中,但听起来可以满足您在此处的要求。

我猜这些“扩展点标识符”不是扩展的唯一标识符,而是它们的类型,因为第545行上也有:
// Extension point identifier constants
UIKIT_EXTERN NSString *const UIApplicationKeyboardExtensionPointIdentifier NS_AVAILABLE_IOS(8_0);

TLDR:禁用自定义键盘,您将在应用程序委托(delegate)中包含以下内容:
- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier {
    if ([extensionPointIdentifier isEqualToString: UIApplicationKeyboardExtensionPointIdentifier]) {
        return NO;
    }
    return YES;
}

关于ios - 我可以为我的应用禁用自定义键盘(iOS8)吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24557373/

10-14 21:15
查看更多