在 Objective C 中禁用 IQKeyboard 管理器
如果您想在项目的特定控制器中禁用IQKeyboardManager。然后在您的 viewController 类中添加这一行。
#import "IQKeyboardManager.h"
现在在 View Controller viewDidLoad方法中,添加以下函数
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:false];
现在,当您离开控制器时,您的IQKeyboardManager将在您离开该 viewController** 时启用。
In **viewWillDisappear** Method:-
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:true];
在 Swift 3.0 中禁用 IQKeyboard 管理器
import IQKeyboardManagerSwift
override func viewDidLoad() {
super.viewDidLoad()
IQKeyboardManager.sharedManager().enableAutoToolbar = false
IQKeyboardManager.sharedManager().enable = false
}
//MARK:- viewWillDisappear
override func viewWillDisappear(_ animated: Bool) {
IQKeyboardManager.sharedManager().enableAutoToolbar = true
IQKeyboardManager.sharedManager().enable = true
}
在 Swift 4.2 中禁用 IQKeyboard 管理器
import IQKeyboardManagerSwift
override func viewDidLoad() {
super.viewDidLoad()
IQKeyboardManager.shared.enableAutoToolbar = false
IQKeyboardManager.shared.enable = false
}
//MARK:- viewWillDisappear
override func viewWillDisappear(_ animated: Bool) {
IQKeyboardManager.shared.enableAutoToolbar = true
IQKeyboardManager.shared.enable = true
}