Pickin' Fruit
Let's make a slot machine!
Instructions
- A picker View "displays a spinning wheel or slot-machine motif of values". I've already placed one on the storyboard. Your job is to implement its 2 delegates.
- The first one is called
UIPickerViewDataSource
. Check out the docs on it...it should look pretty familiar toUITableView
. Implement the required methods on your view controller. There should be three components (i.e., columns), and each component should have one row per symbol in the slot machine. - Now implement the
UIPickerViewDelegate
to put in the appropriate text in each row. Each component (column) should have the same stuff in it.- Here, have some emoji:
๐ ๐ ๐ ๐ ๐ ๐
- Here, have some emoji:
- When the spin button is pressed, use the
selectRow:inComponent:animated:
to randomly spin each component to a row. - When the animations finish, display a
UIAlertController
that says whether you won (i.e., all three components have the same value) or lost. There should be two buttons:Cancel
andSpin Again
. These should do reasonable things.
View Pickin' Fruit on Learn.co and start learning to code for free.