Reputation: 1284
I'm using the following library (which helps to manage multiple textfields)
pod 'IQKeyboardManagerSwift', '~> 4.0'
My question is how would I got about to implement done button action
in our viewController ?
I refer this link.
In IQUIView+IQKeyboardToolbar.swift file this method is available.
public func addDoneOnKeyboardWithTarget(_ target : AnyObject?, action : Selector) {
addDoneOnKeyboardWithTarget(target, action: action, titleText: nil)
}
but I don't understand how to implement in swift code. Please help me..
Upvotes: 1
Views: 1698
Reputation: 721
You can call it on any textField object. for example
[textField1 addDoneOnKeyboardWithTarget:@selector(doneAction:)];
/*! doneAction. */
-(void)doneAction:(UIBarButtonItem*)barButton
{
//doneAction
}
Swift Version:
textField1.addDoneOnKeyboardWithTarget(self, action: #selector(self.doneAction(_:)), shouldShowPlaceholder: true)
func doneAction(_ sender : UITextField!) {
self.view.endEditing(true)
}
Upvotes: 1