Im working with a double (two-component) picker view. When I run it shows me the double picker view, but the same information in both component's rows.
Here is the code hope you can help me.
I want to show in the first component the array1 and in the second component the array2.
- (void)viewDidLoad {
NSArray *FirstArray1 = [[NSArray alloc] initWithObjects:
@"White",@"Whole Wheat",@"Rye",@"Sourdough",@"Seven Grain", nil];
self.Array1 = FirstArray1;
NSArray *FirstArray2 = [[NSArray alloc] initWithObjects:
@"Turkey",@"Peanut Butter",@"Tuna Salad",@"Chicken Salad",@"Roast Beef",
@"Vegemite",nil];
self.Array2 = FirstArray2;
[super viewDidLoad];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 2;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return[self.Array1 count];
return[self.Array2 count];
}
-(NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
return [self.Array1 objectAtIndex:row];
return [self.Array2 objectAtIndex:row];
}
-(NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
if (component == 0) {
return[self.Array1 count];
} else if (component == 1) {
return[self.Array2 count];
}
return 0;
}