如何在iOS应用中禁用第三方键盘

时间:2015-01-23 11:13:29

标签: uitextfield uikeyboard

你可以在iOS中禁用第三方键盘吗?

若然,怎么样?

4 个答案:

答案 0 :(得分:18)

将此方法添加到您的UIApplicationDelegate

-(BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier
    {

        if (extensionPointIdentifier == UIApplicationKeyboardExtensionPointIdentifier)
        {
            return NO;
        }

        return YES;
    }

答案 1 :(得分:3)

Swift 5.1

添加到AppDelegate.Swift:

func application(application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: String) -> Bool {
    if (extensionPointIdentifier == UIApplication.ExtensionPointIdentifier.keyboard.rawValue) {
        return false
    }

    return true
}

答案 2 :(得分:0)

合适的 swift 5.1 版本

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

答案 3 :(得分:0)

对于 Swift 5.4+,它会更快。

在你的类 AppDelegate 中:

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