uitextfield hide keyboard?

牧云@^-^@ 提交于 2019-11-30 15:24:45

If you want the exact same behavior, without the keyboard, try

textfield.inputView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];

Returning NO to UITextFieldDelegate's - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField should do it.

Asike

I think you can use

textfield resignFirstResponder

in delegate method -

(void)textFieldDidBeginEditing:(UITextField *)

textField like this:

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField == yourTextField){
      [yourTextfield resignFirstResponder];
    }
}

use this method to dismiss a keyboard touch anywhere in the view

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}

or by clicking on keyboard done button

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!