swift

Keyboard

class ViewController: UIViewController, UITextFieldDelegate {
    //step1 :conform to UITextFieldDelegate step1
    @IBOutlet weak var nameTextField: UITextField!{
        didSet{
            nameTextField.c=self//setp2:set UITextFieldDelegate
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        nameTextField.becomeFirstResponder()//step 3
        // Do any additional setup after loading the view.
    }
    func textFieldShouldReturn(textField: UITextField) -> Bool {//step 4
        textField.resignFirstResponder()
        return true
    }

}