0

How can I disable the keyboard when I touch-up inside a UITextField?

What I want to do is show a custom digital keyboard instead of the default one.

Anh Pham
  • 2,108
  • 9
  • 18
  • 29
Amine
  • 1,198
  • 11
  • 19

4 Answers4

3

If I understand correctly that you are looking to create a custom keyboard in the app, I don't think we need to disable the default keyboard when we touch-up inside a UITextField.

We just need to create a custom view and assign it to the inputView property of the UITextField to replace the default keyboard.

For example, something like this:

yourTextField.inputView = yourCustomKeyboardView

See more here.

Anh Pham
  • 2,108
  • 9
  • 18
  • 29
0

Note: For Objective-C (Xcode)

In your viewDidLoad: set delegate for textfields which you want to disable.

self.textfield.delegate = self;

and insert this delegate function:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
     if (textField == yourTextfiledOutletInstance) {
         [self showCustomkeyboard];
        return NO;
     }
   return YES;
}

//Show custom keyboard
-(void)showCustomkeyboard{
  // Handle your operation here to show custom keyboard
}
Krunal
  • 77,632
  • 48
  • 245
  • 261
0

set the UITextField delegate in the ViewController class, and then add this method in the class

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

Use resignFirstResponder to dismiss your keyboard.

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

set inputView on the UITextView to the custom view you want to be used in place of the system keyboard.

myTextView.inputView = myCustomView;
Lal Krishna
  • 15,485
  • 6
  • 64
  • 84