Im making an app and I want to fill two UITextView
with two different UIPickerView
.
UIPickerView *inputType;
UIPickerView *inputFormat;
inputFormat=[[UIPickerView alloc] initWithFrame:CGRectZero];
inputType=[[UIPickerView alloc] initWithFrame:CGRectZero];
txtFormat.inputView=inputFormat;
txtType.inputView=inputType;
My problem comes now:
I want to fill the pickers with different data and I don't know how to do it.
I know how to set the datasource for one picker but not for two.
How should I do it?
Take a look at the delegate methods
– numberOfComponentsInPickerView:
– pickerView:numberOfRowsInComponent:
You can figure out which UIPickerView
is asking for it's content by testing the pickerView
variable. Just connect an outlet to both UIPickerView
s. So you can select the same object as the data source of the two picker views.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
if (pickerView == self.firstPickerView) {
return 10;
} else if (pickerView == self.secondPickerView) {
return 15;
}
}