0

I'm very new to Swift programming and one of my first projects is to create a spinning wheel/scroller for a list of ~20 items.

I decided that the best strategy would be to implement what Apple already has: a UIPicker. Unfortunately I also learned that Apple doesn't natively support looping around (i.e. going from 59 back to 0).

This is an issue because the purpose of my project is to allow the user to spin and obtain a "random" result based on the spinner. This doesn't work so well when you are spinning and landing at the top or bottom.

I have looked online for help but everything I found is generally about 4 years old (or more) and thus very outdated. I am new to swift programming and really do not understand this stuff well enough to implement their designs.

I would love an updated strategy for implementing a looping UIPicker or even some other suggestions about how to go about this project. The major problem with other strategies is that I would need to display 20 options which just wouldn't work well with a spinning wheel image.

Philip
  • 1
  • Anything you found is still valid. You just may have to update for Swift 3. – rmaddy Jul 13 '17 at 18:16
  • Hi and welcome to Stack Overflow, please take a time to go through the [welcome tour](https://stackoverflow.com/tour) to know your way around here (and also to earn your first badge), read how to create a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) and also check [How to Ask Good Questions](https://stackoverflow.com/help/how-to-ask) so you increase your chances to get feedback and useful answers. – DarkCygnus Jul 13 '17 at 18:35
  • 1
    Start with your working Swift 3 project with a UIPickerView. Then, look at the answer for this post: https://stackoverflow.com/questions/26063039/uipickerview-loop-the-data -- when you compare that to your "non-wrap-around" code, it should take you less than 5 minutes to have it working. – DonMag Jul 13 '17 at 18:37
  • @DonMag, thanks for the link. I keep running into an error when declaring the pickerViewMiddle. The message is "Cannot use instance member 'pickerViewRows' within property initializer; property initializers run before 'self' is available. Any ideas? – Philip Jul 13 '17 at 19:45
  • I've converted a couple things but I think I am running into trouble since my Picker has strings, not ints. I can't figure out how to fix the rowForValue method. I keep getting an error with the find method. – Philip Jul 13 '17 at 19:46
  • 1
    @Philip - edit your question and post the code you are having trouble with. – DonMag Jul 13 '17 at 19:50

0 Answers0