Reputation: 4127
I have a UITextField
that, when tapped, brings up a UIPickerView
(_myTextField.inputView = _myPicker;
).
However, in the simulator I can use my Macs keyboard to type into the UITextField
. This is not desirable as I am using the UIPickerView
.
How can I disable, or ignore, the hardware keyboard input for the text fields that are using pickers?
Upvotes: 3
Views: 1048
Reputation: 6396
You could use - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
to reject anything that has a single character input (e.g. a key press, which I believe would have a range.length
of 1). This wouldn't help with copy/paste operations, but would cover single keystrokes.
Upvotes: 1
Reputation: 2352
is this that you are looking for?
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
// Here You can do additional code or task instead of writing with keyboard
return NO;
}
I hope this help
Upvotes: 0