Advertise Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Your First iPhone App
($1.99)

iPhone Code Generator
($9.99)

Calcuccino Programmers' Calculator
($2.99)

DataFon(Build Apps on Windows)
(free)

Infinote Pinboard for Todos and Notes
(free)

picplz
(free)

poG
($2.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-18-2008, 04:18 PM   #1 (permalink)
I am evil trapper
 
Join Date: Jul 2008
Location: London
Posts: 290
Default numeral only input field

I have a couple of user definable variables in my app but not sure on the best way to allow these to be configured.

Currently trying to this using a UITextField with the keyboard set to 'number pad' mode, but I can't see how to trap the inputed value because there is no return key on this type of keyboard... so what do i do?
trapper is offline   Reply With Quote
Old 08-21-2008, 11:41 AM   #2 (permalink)
I am evil trapper
 
Join Date: Jul 2008
Location: London
Posts: 290
Default

ok so I figured out a way to save the inputs but discovered a new problem!

The 'number pad' keyboard type doesn't allow a decimal point... so it's either allow all those symbols or allow no decimals

How do the rest of you get numeric inputs from the user??
trapper is offline   Reply With Quote
Old 10-20-2008, 01:17 PM   #3 (permalink)
Registered Member
 
brendand's Avatar
 
Join Date: Aug 2008
Posts: 222
Default

I think the only solution is to implement your own numeric keypad that has a decimal point. That really sucks though. Or I wonder if it would be possible to use the exiting NumerPad and overlay a button with a decimal point on it in the lower left corner?
brendand is offline   Reply With Quote
Old 10-21-2008, 12:57 AM   #4 (permalink)
New Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
Default

What I did is use the normal keyboard but in the text field delegate method 'textField:shouldChangeCharactersInRange:replaceme ntString:' I return NO if the replacement string contains invalid characters (like letters for a number field).

It sucks there is no way to create custom keyboards with just the keys we need so this is what I do until I get the ambition to write from scratch a replacement for the keyboard functionality.
RickMaddy is offline   Reply With Quote
Old 10-21-2008, 06:22 AM   #5 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 56
Default

Can you define the text field to recieve only numeric characters? If so please give and example or explain.
thank you.
natanavra is offline   Reply With Quote
Old 10-21-2008, 09:41 AM   #6 (permalink)
New Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
Default

Read my previous post. I just described how to implement a text field that only accepts specific characters.
RickMaddy is offline   Reply With Quote
Old 10-21-2008, 04:42 PM   #7 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 56
Default

I'm sorry for my ignorance - but where am I supposed to write this piece of code? please about the line of code in a little more detail.
~Thanks in advance.
natanavra is offline   Reply With Quote
Old 10-21-2008, 04:48 PM   #8 (permalink)
New Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
Default

Like I said, read my first post. I clearly state to add this code in the text field's delegate method. The name of the method is in my first post.

May I politely suggest reading the docs on UITextField and UITextFieldDelegate. That may help out some.

The basic idea is that this delegate method gets called on every button you tap on the keyboard, including the delete key. Just reject invalid values based on the needs of your text field.
RickMaddy is offline   Reply With Quote
Old 10-22-2008, 04:02 AM   #9 (permalink)
I am evil trapper
 
Join Date: Jul 2008
Location: London
Posts: 290
Default

For the record I ended up using a picker for numeric input, works pretty nice
trapper is offline   Reply With Quote
Old 02-27-2010, 05:49 PM   #10 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 567
Default

Thanks using shouldChangeCharactersInRange worked very well
aryaxt is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


» Advertisements
» Stats
Members: 51,374
Threads: 52,830
Posts: 225,477
Top Poster: BrianSlick (3,576)
Welcome to our newest member, bob8caldwell
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:27 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0