I have 2 UIPickerviews with the same data. At the moment sb is clicking the save-B开发者_Python百科utton I want to get the data from both PickerViews. I already set a tag to both pickers and I also implemented the function:
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [symbolList objectAtIndex:row];
}
But I have no idea how to get on both datas at the same time.
For each picker view, use selectedRowInComponent:
to find out the current selection. Use this to obtain the value from each picker view's data source, e.g:
NSString *pickerViewOneSelection = [symbolList objectAtIndex:[pickerViewOne selectedRowInComponent:0]];
NSString *pickerViewTwoSelection = [symbolList objectAtIndex:[pickerViewTwo selectedRowInComponent:0]];
I'm assuming that pickerViewOne
and pickerViewTwo
are pointers to your two picker views and you've already worked that part out. I have also assumed that your picker has only one component.
Set tag of pickerview. first create IBOutlet of both picker view.
and set tag of picker view. pickerview.tag == 10;
精彩评论