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

mat*_*atm 27 ios ios8

编辑:tl;博士 - 有可能,见下面接受的答案.

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

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

我得到的印象是App Extension Programming Guide,MDM(移动设备管理)可以限制设备使用自定义键盘,但我没有在Apple Configurator.appOS X Yosemite 的新测试版中找到该选项."Configurator"是否缺少该选项?

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

Fil*_*lic 49

看起来你在beta种子3中得到了你想要的东西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);
Run Code Online (Sandbox Code Playgroud)

它目前没有包含在文档中,但听起来它会完全按照您的要求进行操作.

我猜这些"扩展点标识符"不是扩展名的唯一标识符,而是它们的类型,因为第545行也是如此:

// Extension point identifier constants
UIKIT_EXTERN NSString *const UIApplicationKeyboardExtensionPointIdentifier NS_AVAILABLE_IOS(8_0);
Run Code Online (Sandbox Code Playgroud)

TLDR:要禁用自定义键盘,您需要在应用委托中包含以下内容:

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

  • 仅供参考 - 这确实适用于iOS 7 SDK.(测试)实际上......它甚至适用于iOS 6 SDK.(测试) (2认同)

wuf*_*810 10

斯威夫特3:

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


Sug*_*gat 6

我只想为那些想要在 Xamarin iOS 中实现此方法的开发人员添加此内容。这个想法是覆盖ShouldAllowExtensionPointIdentifier你的方法AppDelegate

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