• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa-dev Digest, Vol 8, Issue 565
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa-dev Digest, Vol 8, Issue 565


  • Subject: Re: Cocoa-dev Digest, Vol 8, Issue 565
  • From: Martin Stanley <email@hidden>
  • Date: Wed, 27 Jul 2011 17:58:47 +0200

(oops, corrected response below; sorry)

I also have implemented a UITextField for numeric (currency and percentage) input. Here is my experience:
1- I found the Number Pad keyboard fatally lacking due to omission of a decimal point character and a "Done" key. So use a Numbers and Punctuation keyboard.
2- I did not use a UIPickerView because I think this is too much work for the user. (This of course is debatable).

I used:
	-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
to disallow unwanted characters based on context and:
	- (BOOL)textFieldShouldEndEditing:(TVDecimalNumberTextField *)textField
to ensure an in-range value.

Hope this helps,
Martin

On 2011-07-26, at 6:43 AM, email@hidden wrote:

> Message: 5
> Date: Mon, 25 Jul 2011 19:29:06 -0700
> From: Howard Siegel <email@hidden>
> Subject: Re: UITextField Questions
> To: "email@hidden" <email@hidden>
> Cc: Brooke Gravitt <email@hidden>
> Message-ID:
> 	<email@hidden>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Mon, Jul 25, 2011 at 18:31, Brooke Gravitt <email@hidden> wrote:
>
>> On Mon, Jul 25, 2011 at 9:19 PM, Conrad Shultz
>> <email@hidden> 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 (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

  • Prev by Date: Re: Cocoa-dev Digest, Vol 8, Issue 565
  • Next by Date: Re: Two NSTableViews, two data sources, one data model?
  • Previous by thread: Re: Cocoa-dev Digest, Vol 8, Issue 565
  • Next by thread: UIAlertView with UITextField
  • Index(es):
    • Date
    • Thread