how can I dismiss keyboard on Enter keypress

前端 未结 4 835
无人共我
无人共我 2021-01-15 12:28

I want to dismiss my keyboard as I press RETURN key.

I have tried by putting button in view\'s back side.

But how can I do this by pressing RETURN key?

4条回答
  •  不知归路
    2021-01-15 13:01

    I hope you have done UIViewController and yourTextField.delegate=self;

    and then in the delegate method

    - (BOOL)textFieldShouldReturn:(UITextField *)textField;
    {
    
       [textField resignFirstResponder];
       return YES;
    
    }
    

提交回复
热议问题