How to make return key on iPhone make keyboard disappear?

后端 未结 14 531
有刺的猬
有刺的猬 2020-12-02 07:06

I have two UITextFields (e.g. username and password) but I cannot get rid of the keyboard when pressing the return key on the keyboard. How can I do this?

14条回答
  •  清歌不尽
    2020-12-02 07:53

    Took me couple trials, had same issue, this worked for me:

    Check your spelling at -

    (BOOL)textFieldShouldReturn:(UITextField *)textField {
        [textField resignFirstResponder];
    

    I corrected mine at textField instead of textfield, capitalise "F"... and bingo!! it worked..

提交回复
热议问题