I am setting up a UIPickerView to have choices like choice a, choice b, choice c and so on. I have tried to interpret the sample code from Apple but that seems very difficult to understand for a beginner like me. I also would like the choices from the picker view to take me to another page if that is possible.
I am setting up a UIPickerView to have choices like choice a , choice
Share
It’s obvious for every beginner that it is some what tedious to understand these things the first time.
Anyways, do you know how to use
UITableViews? Do you know how to useUITableViewDelegateandUITableViewDataSource? If your answer is yes, then just imagineUIPickerViews are likeUITableViews (but remember they are notUITableViewControllers).Let’s say, I’ve a
UIPickerView:1) First you need to assign the
delegateanddataSourceto theUIPickerVieweither via IB or code. It depends on your implementation (So this step looks very similar to aUITableView, doesn’t it?)Like this:
2) Next, you need to define number of sections, like this:
2) Then you need to define the number of rows you need:
3) Then, define title for row (And if you have multiple section, then title for each section):
4) Next, you need to get the event when someone clicks on an element (As you want to navigate to other controller/screen):
That’s all the implementation you need.