Ravi Ravi - 6 months ago 21
Objective-C Question

Don't show the keyboard when I tapped in TextField

I am new to Objective C and iOS development in general. I am trying to create an app that would make an

UITextField
to tapped. I want the keyboard not to show when I tap on the
textfield
. then I want many times to tap textfield and don't show the keyboard.

I share the Screenshot

I Want to try this code but it didn't work.

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField resignFirstResponder];
}

Answer

you can called this functions in delegate methods

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    if (!textField.inputView) {
        //it hides the keyboard, but cursor will show
        textField.inputView = [[UIView alloc] initWithFrame:CGRectZero];
    }
    return YES;
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    return NO;
}
Comments