Re: UIPickerView and multiple text fields, iOS
Re: UIPickerView and multiple text fields, iOS
- Subject: Re: UIPickerView and multiple text fields, iOS
- From: Fritz Anderson <email@hidden>
- Date: Fri, 20 Sep 2013 13:27:30 -0500
On 20 Sep 2013, at 11:54 AM, Chris Paveglio <email@hidden> wrote:
> Currently I have my text field subclassed and it's the <UIPopoverControllerDelegate, UIPickerViewDataSource, UIPickerViewDelegate> for the picker. I'm using this to try to force updating of the 2nd (numeric) field as the picker is scrolled, but since the picker is in the foreground it's crashing, I figure since it won't let other messages through till it's dismissed. I don't want to wait till the picker is dismissed to display the value.
repeat N times; "No. "; end
Do not use view classes as controllers. Especially, do not use controls as controllers. (In general, subclassing standard controls is a smell.) Do not make any view aware of the control or data structure of your application. (Unless one of your model types amounts to being the view's value.)
Make your view controller all of those delegates. Have it receive the picker-changed callbacks. Have it look up the value corresponding to the selected item. Have it update any fields, labels, whatever you want in response. Go nuts. You don't have to worry what the First Responder is. (Am I right that one of these "fields" is actually a UILabel?)
If you're presenting the picker modally, I'm surprised your presentation doesn't obscure the field anyway. In that case, your controller doesn't have to update the model and reset the UI until the modal view is gone.
Does the field have to be free-form editable independent of the picker? If not, don't make it a field; fields are for free-form editing. Make it a button displaying the value, and put up the picker when you tap it. Even if you were doing free-form entry, I'd consider that button, and put up a field-and-picker modal view to edit it, rather than edit it in place.
And any opinion on UI design (including this one) is worthless without user testing.
— F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden