views:

187

answers:

2

I am currently using a UIPIckerView in my app to allow a user to select from a list of options. The problem is that there isn't enough of a delay when the user stops spinning the wheel and it is selecting a value before the user has a chance to scroll further down the list.

Is there a way to override the default behavior that selects the row as soon as the wheel stops spinning and the user removes their finger? I see Mobile Safari includes a "Done" button which would be great.

I can provide code if necessary (not sure how it would help).

Thanks!

+3  A: 

You can add this manually; just add a done button to the view that holds the UIPicker, and have IT do whatever action you're currently performing in – pickerView:didSelectRow:inComponent:.

Ben Gottlieb
Thanks, I was making it way more difficult than it needed to be. I ended up putting a UIToolbar attached to the top of the picker with a done button that hides itself and the picker. It works great, I had a serious brain lapse when I posted that question!
Eric
+1  A: 

The UIPickerView automatically selects which ever row stops in the center. It does not work like a table but more like a popup menu. As such, you can't use a picker view like a button to call an action because it will trigger the moment the user stops moving it whether that represents their final choice or not.

Instead, as noted previously, you need a second control element (usually a button) to call the action that makes use of the pickerview's selection.

TechZen