Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the text of selected rows #3

Closed
haxinc opened this issue Apr 12, 2014 · 5 comments
Closed

Get the text of selected rows #3

haxinc opened this issue Apr 12, 2014 · 5 comments

Comments

@haxinc
Copy link

haxinc commented Apr 12, 2014

Hi,

How chould I get the text/NSString of selected rows ?

  • (void)pickerViewController:(RMPickerViewController *)vc didSelectRows:(NSArray *)selectedRows

Thanks

@CooperRS
Copy link
Owner

selectedRows is an array containing NSNumbers. selectedRows[0] contains the selected row in component 0 of your picker view. selectedRows[1] contains the selected row in component 1 of your picker view and so on.

Therefore, you can get the title of the selected row in a certain component just like you calculated the title in

  • (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component

or

  • (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view

Hope this helps :)

@haxinc
Copy link
Author

haxinc commented Apr 12, 2014

Hmmm I think I didn't get the point since I tried selectedRows[0] it also shows number

@CooperRS
Copy link
Owner

Right, selectedRows[0] contains the selected row in component 0. Knowing the index of the selected row also means that you know the title, as in

  • (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component

or

  • (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view

you also need a title for a certain index. You just need to re-use that knowledge.

@haxinc
Copy link
Author

haxinc commented Apr 12, 2014

Okay, I understood .. Thank for a rapidly reply!

@CooperRS
Copy link
Owner

Ok, then I will close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants