开发者

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

开发者 https://www.devze.com 2023-04-09 22:24 出处:网络
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 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

精彩评论

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