1

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..

Lamour
  • 3,002
  • 2
  • 16
  • 28
NiravS
  • 1,144
  • 1
  • 12
  • 24

1 Answers1

1

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)
}
yogesh wadhwa
  • 711
  • 8
  • 16
  • Please give the swift version of your code , that will be more helpful as the OP specifically asked for swift – 3stud1ant3 Sep 12 '17 at 04:30