How to dismiss keyboard on a UIWebView?

前端 未结 5 511
别那么骄傲
别那么骄傲 2021-01-31 21:05

I am loading an HTML page that has a form. I would like to be able to dismiss the keyboard when the user clicks on GO or if he clicks on the SUBMIT button on the HTML page.

5条回答
  •  野性不改
    2021-01-31 22:04

    I'm not so familiar with UIWebView, but normally you would dismiss your keyboard like so...

    [textField resignFirstResponder];
    

    By doing that, the keyboard would be dismissed...

    To have the keyboard be dismissed when say the user clicks the return button, you would need to implement the delegate method.

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

    Apple's documentation has a full list of methods for the UITextFieldDelegate.

提交回复
热议问题