My app collects various types of information and sends it off to our server. Some of the questions are of fixed type so I need to use Pickers. When I've used pickers before they are initialised when the app starts with the array of selections. I had thought I would use different pickers through various subViews. Would it be better to use just one Picker and then reset the array used dynamically. If so how do I do this?
Asked
Active
Viewed 453 times
0
-
you mean that loading same picker with different array on different event? – Yama Dec 29 '11 at 12:42
2 Answers
1
Note that each method of both the datasource and the delegate protocols contain a UIPickerView * parameter, for instance:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
You need to use it to distinguish between your two instances, as follows:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
if([pickerView isEqual: pickerOne]{
// return the appropriate number of components, for instance
return 3;
}
if([pickerView isEqual: pickerTwo]{
// return the appropriate number of components, for instance
return 4;
}
}

Rakesh Bhatt
- 4,606
- 3
- 25
- 38
-
Answer copied from http://stackoverflow.com/a/768126/1228. Please read http://blog.stackoverflow.com/2009/06/attribution-required/ – Robert Harvey May 14 '12 at 18:15