0

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?

user616076
  • 3,907
  • 8
  • 38
  • 64

2 Answers2

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
0

Give the two different tags. And compare tag for loading your array.

Devang
  • 11,258
  • 13
  • 62
  • 100