Reputation: 60869
I am encountering a funny problem with UIPickerView. My data source has 2 items:
"All" and "Home"
When I select one, I execute a certain task.
By default All is selected. When I click on Home my task executes, and then when I choose the picker again, it is set to All. In order to select All, I have to scroll up a bit, so that the selection is off All, and then let go so it falls back down to All.
What is the best way to be able to select All?
Upvotes: 0
Views: 1287
Reputation: 21893
What you want is to call:
[myPickerView selectRow:0 inComponent:0 animated:NO];
That'll actually DO the selection action, and fire it as if it was just chosen. If you wanted, you could make it roll to the thing visually by saying animated:YES
, but you probably don't really want that, you just want to initialize the picker and fire the first option.
Upvotes: 3