How to hide keyboard in swift on pressing return key?

I am using UITextfied while clicking on textfied keyboard appear but when i pressed the return key, keyboard is not disappearing. I used the following code:

func textFieldShouldReturn(textField: UITextField!) -> Bool // called when 'return' key pressed. return NO to ignore.
{
    return true;
}

the method resignfirstresponder is not getting in function.

20 Answers
20

Leave a Comment