IQKeyboardManager 的完成按钮操作在 Swift 中不起作用

Done button action from IQKeyboardManager not working in Swift

我们正在为 Swift 项目使用 IQKeyboardManager 库。它工作正常,但是,单击 "Done" 按钮后,它没有调用该方法。

 override func viewDidLoad() {
        super.viewDidLoad()
        self.myTextField.delegate = self
        self.myTextField.keyboardToolbar.doneBarButton.setTarget(self, action: #selector(doneButtonClicked))
}

 @objc func doneButtonClicked(_ sender: Any) {
        //your code when clicked on done

    }

库版本为

pod 'IQKeyboardManagerSwift', '6.0.2'

有什么建议吗?

// Don't set button for keyboardToolbar. Set button direct to textfield.
    self.myTextField.doneBarButton.setTarget(self, action: #selector(self.doneButtonClicked(_:)))

这是 IQKeyboardManagerSwift 版本 6.0.2

中的问题

Fixed issue

您可以使用UITextFieldDelegate

   func textFieldDidEndEditing(_ textField: UITextField) {

        print("done click ")
 }

或更新IQKeyboardManagerSwift 6.0.3

pod 'IQKeyboardManagerSwift', '6.0.3'