I want to show a UIPickerView on becoming FirstResponder of a UITextfield not the keyboard and fill the value in text field form the picker view.
any one knows this?
Use [textfield setInputView:pickerView];
Replacing the System Input Views
inputView
inputAccessoryView
Edit: this answer was correct at the time of writing. Apple has since introduced inputView
. Mafonya answer is what you should be doing nowadays.
It is possible to prevent the keyboard from popping up. Set your class to be the delegate of the UITextField: textField.delegate = self
and add: <UITextFieldDelegate>
after your interface declaration (before the {) in the header file.
Now implement textFieldShouldBeginEditing:
:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
// Show UIPickerView
return NO;
}
If you want to be able to hide your pickerView this method won't work. What you could do then is create subclass of UITextField and override the *trackingWithTouch:event:
selectors and do your magic in those. You probably still need to return NO from textFieldShouldBeginEditting:
to prevent the keyboard from showing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With