Anilkumar iOS Developer
Anilkumar iOS Developer

Reputation: 3755

Done button action from IQKeyboardManager not working in Swift

We are using IQKeyboardManager library for Swift project. Its working fine, but, After clicking the "Done" button its not calling the method.

 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

    }

And the library version is

pod 'IQKeyboardManagerSwift', '6.0.2'

Any suggestions?

Upvotes: 2

Views: 5538

Answers (2)

Yagnesh Dobariya
Yagnesh Dobariya

Reputation: 2251

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

Upvotes: 0

a.masri
a.masri

Reputation: 2469

This is issue in IQKeyboardManagerSwift version 6.0.2

Fixed issue

You can use UITextFieldDelegate

   func textFieldDidEndEditing(_ textField: UITextField) {

        print("done click ")
 }

or update IQKeyboardManagerSwift 6.0.3

pod 'IQKeyboardManagerSwift', '6.0.3'

Upvotes: 3

Related Questions