On Mon, Jul 25, 2011 at 18:31, Brooke Gravitt <bro...@gravitt.org> wrote:
> On Mon, Jul 25, 2011 at 9:19 PM, Conrad Shultz > <con...@synthetiqsolutions.com> wrote: > > Take a look at UITextInputTraits to specify a numeric keyboard. (IIRC > this can be done in IB too.) > > > > Take a look at UITextFieldDelegate's textFieldShouldEndEditing: method to > perform validation of input. > > > > I should also point out that often a text field is not the most > appropriate control for restricted numeric input. If you have a reasonably > small finite set of input values, consider UIPickerView. If you have a > finite range for input, consider UISlider. > > > > (Sent from my iPhone.) > > > > -- > > Conrad Shultz > > Conrad, > > Thanks for the response! The fields in question are for setting a > price and a percentage, respectively. They don't seem to fit into > either category. I'll take a look at the UITextInputTraits && the > delegate's textFieldShouldEndEditing method as well! > > Thanks! > > Brooke > Brooke, You would likely be much better off using UIPickerViews, or a UIPickerView and a UISlider as Conrad suggests. If the UISlider doesn't give you enough selection precision, then use another UIPickerView. You use the UITextField to keep the value for display purposes, but use the UIPickerViews for the value selection. In order to use the UITextField for display and the UIPickerView for the value selection instead of the keypad you would need to create the UIPickerViews and then set the UITextField inputView to the appropriate UIPickerView. When the user taps in the text field, instead of a keypad coming up, the picker view will come up. You can also set the inputAccesoryView to a UIToolbar that contains a "done" button so the picker view can be dismissed once the user selects the value. The picker view for the percentage would contain 2 or 3 columns for the decimal part (0 to 100) and as many columns for the fractional part as needed. The picker view for the price would contain as many columns for the dollar amount and 2 columns for the pennies. This assumes that the price value isn't too outrageously large that you can't fit the dollar amount in to columns such that the picker view becomes too wide, and you can get pretty wide if you drop the font size used for the columns. I can dig out some links to StackOverflow threads that I used to code up exactly this type of user interface in an app that I am writing. - h _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com