开发者

Multiple UIPickerView with same data in one view. How can I get the content of both picker?

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;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜