基本上就是这样,我还没有找到在我的应用程序中禁用第三方键盘的方法,尽管我知道这是可能的,因为我在 1Password 等应用程序中看到过它。
有什么想法吗?
将此代码添加到您的
AppDelegate
func application(application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: String) -> Bool {
if extensionPointIdentifier == UIApplicationKeyboardExtensionPointIdentifier {
return false
}
return true
}
斯威夫特4:
func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplicationExtensionPointIdentifier) -> Bool {
if extensionPointIdentifier == UIApplicationExtensionPointIdentifier.keyboard {
return false
}
return true
}
斯威夫特5
func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplication.ExtensionPointIdentifier) -> Bool {
if extensionPointIdentifier == UIApplication.ExtensionPointIdentifier.keyboard {
return false
}
return true
}
苹果参考。
斯威夫特 3 :
func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplicationExtensionPointIdentifier) -> Bool {
if extensionPointIdentifier == UIApplicationExtensionPointIdentifier.keyboard {
return false
}
return true
}
斯威夫特4.2
func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplication.ExtensionPointIdentifier) -> Bool {
if extensionPointIdentifier == UIApplication.ExtensionPointIdentifier.keyboard {
return false
}
return true
}
在 Swift 5.0 中
func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplication.ExtensionPointIdentifier) -> Bool {
return extensionPointIdentifier != UIApplication.ExtensionPointIdentifier.keyboard
}
func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplication.ExtensionPointIdentifier) -> Bool {
return extensionPointIdentifier != .keyboard
}