我可以为我的应用禁用自定义键盘(iOS8)吗? [英] Can I disable custom keyboards (iOS8) for my app?

查看:206
本文介绍了我可以为我的应用禁用自定义键盘(iOS8)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

是否有任何(不仅仅是程序)方式阻止自定义键盘(iOS8)用于我的应用程序?我主要对每个应用程序设置感兴趣,所以我的应用程序不允许使用自定义键盘,但在系统范围内禁用自定义键盘是最后的选择。

Is there any (not only programatic) way of preventing custom keyboards (iOS8) from being used for my application? I am mainly interested in "per-app" setting, so just my app is not allowed to use custom keyboards, but disabling custom keyboards system-wide is last resort.

到目前为止,我知道自定义键盘是系统范围的,可以被任何应用程序使用。操作系统将仅回退到库存键盘以进行安全文本输入(文本字段 secureTextEntry 设置为 YES )。这里没什么希望。

So far I know that custom keyboards are system-wide and can be used by any application. The OS will fallback to stock keyboard only for secure text entry (text fields with secureTextEntry set to YES). Not much hope here.

我从 App扩展编程指南得到的印象是MDM(移动设备管理)可以限制设备完全使用自定义键盘,但我没有在OS X Yosemite的新测试版 Apple Configurator.app 中找到该选项。 'Configurator'是否缺少该选项?

I got an impression from App Extension Programming Guide that MDM (Mobile Device Management) can restrict device from using custom keyboards at all, but I didn't find that option in the new beta version of Apple Configurator.app for OS X Yosemite. Is 'Configurator' just missing that option?

这里有什么想法吗?我应该提交雷达来建议Apple应该引入这样的功能吗?

Any ideas here? Should I file a radar to suggest that Apple should introduce such functionality?

推荐答案

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

Looks like you got what you wanted in beta seed 3. Line 440 of UIApplication.h:

// 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);

它目前不包含在文档中,但听起来它会完全按照您的要求执行。

It's not currently included in the docs, but sound like it will do exactly what you asked here.

我猜这些扩展点标识符不是扩展名的唯一标识符,而是其类型的唯一标识符,因为第545行还有这个:

I'm guessing these "extension point identifiers" are not unique identifiers of extensions, but of their types, as there is also this on line 545:

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

TLDR:以禁用自定义键盘,您可以在app delegate:

TLDR: to disable custom keyboards you would include something like this in your app delegate:

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

这篇关于我可以为我的应用禁用自定义键盘(iOS8)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆