Reputation: 1336
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.
Upvotes: 0
Views: 3453
Reputation: 2118
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.
Upvotes: 3
Reputation: 16160
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;
Upvotes: 0
Reputation:
set the UITextField delegate in the ViewController class, and then add this method in the class
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
Upvotes: 0
Reputation: 79646
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
}
Upvotes: 0