I have a UIPickerView
on my UIView
along with a UITextField
. I am letting the user select a value from the picker or enter a custom va
Instead of "pushing" the value of the picker each time you make a selection with this code:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
you should "pull it" when the user clicks the button (or other event you are using) using something similar to:
- (void)myAction:(id)sender
{
NSInteger row = [myPicker selectedRowInComponent:0];
selectedText = [myArray objectAtIndex:(NSUInteger)row];
}
For clearing the text: The UITextField
class provides a built-in button for clearing the current text. So if the user does not want that text he can discard it.
myTextField.clearButtonMode = UITextFieldViewModeAlways;
So in the script, will you check if the TextField
has a value, if it does have a value u use the TextField, if it doesn't have a value, you pull the information from the Picker
.