Last Updated: February 25, 2016
·
3.176K
· gabrielwebb

UIPickerView -Spin Tutorial

OK. So I wanted to know this for awhile. How do they do it ? I've seen many apps use this(e.i Urbanspoon,Casino Games) and after countless lines of code implementing the actual UIPickerView,(That of which is more lines than I initially thought) I finally got down to figuring this beast of an IBAction out. I scoured the interwebz. I came up empty handed. Everything I found had tons of deprecated code or was not what I was looking for at all. So I figured I would reach out to a friend. Andy Roth saved the day and I knew it was only a few lines. So here are the lines incase you are desperate like I was

[picker1 selectRow:(arc4random() % [self pickerView:picker1 numberOfRowsInComponent:0]) inComponent:0 animated:YES];

And there you have it. lol not a lot. I named my UIPickerView picker1 so just swapped out what you declared your UIPickerView as and throw this block into your IBAction and you're set. Hope this helped

1 Response
Add your response

can you pls provide sample code for this app?

over 1 year ago ·