I am new in ios I work on iqkeyboardmanager and I want to access Done button action in IQKeyboardManager.
You can handle clicks of done, next and previous button
[textField.keyboardToolbar.previousBarButton setTarget:self action:@selector(previousAction:)];
[textField.keyboardToolbar.nextBarButton setTarget:self action:@selector(nextAction:)];
[textField.keyboardToolbar.doneBarButton setTarget:self action:@selector(doneAction:)];
In swift:
customField.keyboardToolbar.doneBarButton.setTarget(self, action: #selector(doneButtonClicked))
func doneButtonClicked(_ sender: Any) {
//your code when clicked on done
}
you can use UITextViewDelegate
func textFieldDidEndEditing(_ textField: UITextField) {
}
You can import
import IQKeyboardManager
in required file and after that
vc1Textfield.addDoneOnKeyboard(withTarget: self, action: #selector(doneButtonClicked))
here vc1Textfield is my textfield and doneButtonClicked definition is given below:
@objc func doneButtonClicked(_ sender: Any) { }
Hope it help someone!!! Happy Coding....
I will try to describe in a more convenient way:
import IQKeyboardManagerSwift
class EditPostViewCell: UITableViewCell {
@IBOutlet weak var commentTextView: UITextView!
override func awakeFromNib() {
IQKeyboardManager.shared.toolbarDoneBarButtonItemText = "Send Comment"
commentTextView.delegate = self
}
@objc func didPressOnDoneButton() {
commentTextView.resignFirstResponder()
sendComment()
}
}
extension EditPostViewCell: UITextViewDelegate {
public func textViewDidBeginEditing(_ textView: UITextView) {
let invocation = IQInvocation(self, #selector(didPressOnDoneButton))
textView.keyboardToolbar.doneBarButton.invocation = invocation
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With