ios 指定页面禁用第三方键盘,使用系统的键盘

因为项目需要,需要在添加银行卡和提现页面使用数字键盘, 如果用户没有安装第三方键盘是没啥大问题的,但是如果用户手机安装了第三方的键盘的话,有时候会无法调用起第三方的数字键盘,或者第三方键盘样式不符合,这个时候系统的数字键盘是比较符合我们的需求的。那么我们如何在特定的页面使用系统自带的数字键盘呢?

其实简单我们只需要实现 UIApplicationDelegate 的如下代理方法即可:

   /// 此方法的作用是是否使用第三方键盘
///
/// - Parameters:
/// - application: application 对象
/// - extensionPointIdentifier: 第三方键盘的标识
/// - Returns: true 表示使用第三方键盘 fanse 表示不使用
func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplicationExtensionPointIdentifier) -> Bool {
//遍历当前根控制器的所有子控制器找到我们需要的子控制器
for vc in (self.window?.rootViewController?.childViewControllers)! {
//这里的MainNavigationController是我自定义的导航控制器
if vc.isKind(of: MainNavigationController.self) {
for vc1 in vc.childViewControllers {
//如果是 添加银行卡界面 和 提现页面 禁止使用第三方键盘
if vc1.isKind(of: AddBBankCardController.self) || vc1.isKind(of: WithdrawViewController.self) {
return false
}
}
}
}
return true
}

关于系统自带的数字键盘无法输入小数点的问题如何解决请看我的另一篇文章:  ios自定义数字键盘

上一篇:ubuntu14.04 LTS 更新源


下一篇:.net 和 core2.0 数据库连接字符串