尝试为特定的ViewController或整个应用禁用IQKeyboardManager
,它无效。
我的AppDelegate代码:
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:NO];
[[IQKeyboardManager sharedManager] setEnable:NO];
[[IQKeyboardManager sharedManager] disableToolbarInViewControllerClass:[TCChatViewController class]];
[[IQKeyboardManager sharedManager] disableInViewControllerClass:[TCChatViewController class]];
还尝试在viewWillAppear:
中停用:
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:NO];
[[IQKeyboardManager sharedManager] setEnable:NO];
答案 0 :(得分:5)
在Objective C中禁用IQKeyboard Manager
如果要在特定控制器中禁用 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 Manager
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 Manager
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
}
答案 1 :(得分:1)
问题出现在“两者都实现的类”中,因为库包含在主应用和框架中。所以我想我正在将库首选项设置为一个副本,但是库正在从另一个副本中读取首选项,而我的被忽略了。
答案 2 :(得分:1)
尝试一下
[[IQKeyboardManager sharedManager] setEnable:NO];
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:NO];
[[IQKeyboardManager sharedManager] setShouldResignOnTouchOutside:NO];
答案 3 :(得分:0)
在Swift 5中,这对我特别适用于vc:
IQKeyboardManager.shared.disabledDistanceHandlingClasses.append(MyController.self)
IQKeyboardManager.shared.disabledToolbarClasses = [MyController.self]