I am using two UIPickers in a view. first picker has 3 components and second has one. but when I select items, it shows correct items from first picker but always return first item from second picker regardless of selected row. Please help.
here is the code I am using.
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
if (pickerView == triplePicker)
return 3;
else {
return 1;
}
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (pickerView == triplePicker) {
if (component == kColorComponent)
return[colorList count];
if (component == kClarityComponent)
return[clarityList count];
return[shapeList count];
}
else{
return [listPickerItems count];
}
}
-(NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
if (pickerView == triplePicker) {
if (component == kColorComponent)
return [colorList objectAtIndex:row];
if (component == kClarityComponent)
return [clarityList objectAtIndex:row];
return [shapeList objectAtIndex:row];
}
else{
return [listPickerItems objectAtIndex:row];
}
}
in buttonpressed event I have following for second picker to return the item selected:
NSInteger pickrow = [listPicker selectedRowInComponent:0];
NSString *picked = [listPickerItems objectAtIndex:pickrow];