I have 8 textfields in one view. I want to populate each using a pickerview. Can I have 1 pickerview which will display different list of items from different arrays for dif
I have tested this code with 3 textfields.
And found perfect solution of your problem.
1) Take one global UITextField.
2) On delegate method of textfield edit, set global textfield to current textfield.
3) On picker value change method, set the text of global textfield and it'll change the value of selected textfield.
Below code is working properly.
Enjoy coding.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component
{
return 10;
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [NSString stringWithFormat:@"Test %d",row + 1];
}
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
test.text = @"XYZ";
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
test = textField;
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}