I need to figure out how to add a custom keypad to a textfield. What I really need is a decimal point and and add button along with the normal numbers and done button.
Any clues anyone?
Thanks
Have a look here:
http://keith-wood.name/keypad.html
It seems to be quite flexible and allows localization and customization (don't forget that some people use decimal comma instead of point)
Related
HI.
I am developing an iphone app where i just want to use numbers from the iphone keypad. I am using the UIKeyboardTypeNumbersAndPunctuation keyboard, and ideally just want to display the keys of 0-9 from the top row of this keyboard.
Is there any way to do this, like change the position of the keyboard so that only the top row is displayed?
thanks
Kim
did you tryUIKeyboardTypeNumberPad ?
I wouldn't approach it this way, since you would also hide the "Done" button to dismiss the keyboard. In any way, this would look like a bad hack.
Why not making your own keyboard control which looks and acts exactly what you want it to do? That would seem to be the clean way to do it to me.
HI, yes i tried UIKeyboardTypeNumberPad, but it takes up too much real estate on the screen, i have decided to build my own simple number pad.
thanks
Kim
I need to learn about ways of doing this. The options I am aware of are:
1) Load my own custom font which includes subscripted letters, or
2) Simulate a "placeholder" with two UILabels positioned directly over the UITextField, and make those labels go away when the user starts typing. In my case, this will be more work than it sounds like, because the whole thing will need to be data-driven.
Are there other options?
As best I can tell, the answer is "no".
I want to create my own number pad to appear after user focus the textfield, so I have two question about it?
1.I use "Interface Builder to add a textfield in my view and select the "Number Pad" as the default pad for user to input number, so when I click the textfield, the number pad appear automaticlly, how can I stop it appear the number pad? because I want to show my number pad.
2.If I custom a view with number button inside it, how can I detect the event when I click the textfield? and whether after I detect the event I add a subview to show my custom number pad or not?
thanks
If you are creating a custom number pad (I assume this means a view with a grid of buttons), don't bother using a UITextField; there is no easy way to hide the native keyboard and, for all that trouble, there is nothing useful that the text field gives you.
I recommend creating a custom UIControl subclass. You can detect a touch inside the view and show your custom keypad that way. The documentation explains this pretty well.
I have a partial answer but not an ideal one, and I haven't tried this myself. Take a look at the documentation for the UITextFieldDelegate protocol.
You could have your controller set textField.delegate = self, then have it implement textFieldShouldBeginEditing to show your specialized keyboard somehow and then return NO so that it doesn't go into edit mode. When you tell your special keyboard to show itself, pass it a reference to the text field so it knows where to insert characters. The problem is that this probably won't show a cursor and won't let the user move the cursor to insert characters, etc.
So really this a bit ugly, but it may be sufficient. AFAIK there is no good way to do this :(
My users need to enter latitude and longitude, and of course I need to verify that the values entered are legitimate lat/long value. I'd like to have a keyboard layout that does some of this for me (eliminating alphabetic characters, punctuation, etc, and leaving only the numbers and +/-). The number pad keyboard doesn't seem to do it (missing +/-) and neither do any other keyboard layouts that come with the SDK. Does anyone know if there is a way to provide that capability without doing my own keyboard IME and jailbreaking the phone?
Thanks!
I know this is answer is way late, but this topic was still relevant to me. Therefore I have hope the following will help someone who comes across this page.
Bryan S. Gruver posted a full Xcode project that lambdabunny could modify ever so slightly in order to achieve their aim. You can find it here:
http://brygruver.squarespace.com/blog/2009/10/1/creating-a-custom-number-pad.html
Update
The Squarespace link is now broken. Another option is:
https://github.com/lnafziger/Numberpad
How about placing a "+/-" button next to your UITextView that would switch the sign of the entered text? Or a "+" button that appears to the left of it that switches the button label from "+" to "-" each time you tap it.
You don't have to jailbreak.
If you create a view to simulate the keyboard you're still following the SDK rules.
What I'm trying to do is replicate the NSTokenField like UITextField seen in the Mail app and Messages app (type a contact and it comes up with suggestions).
I've got the autocompleting working perfectly, when you type in a UITextField, a UITableView pops up showing any matches that it can find in an array, when you click one it adds it to the UITextField. I'm really happy with this so far.
The problem I've run into now is making the controls look like those in the native apps. Afterall, design is everything!
My first question is how can I add that shadow look to the UITableView? Looks like it's sunk down behind the UITextField.
Secondly, I know I'm going to have to subclass the UITextField to make it look the way I'd like it to, but I've got no idea where to start with that. Some pointers or a sample would be great!
Lastly, I think I need to create a custom UIButton with space for text and the blue gradient then add it to the UITextField. Same problem as with the UITextField, not really sure how to subclass the UIButton (what methods it needs to draw and stuff) or how to add it to the UITextField in such a way that when you click backspace on in the UITextField, the button will be highlighted, then deleted if backspace is clicked again (exactly how the NSTokenField works).
I've included an image just so you can see what I'm talking about:
http://www.thermoglobalnuclearwar.com/stuff/mail.jpg
I have taken a look at Joe Hewitts Three20 project but I couldn't make heads or tails of it.
I'd like to start very simply and understand everything that's going on rather than just dragging his code into mine and not having any idea what's going on!
Any help is greatly appreciated!
Thanks,
Tom.
Have you considered using the Three20 library? It contains a control which I think does what you want (TTPickerTextView).
As the website description states
TTPickerTextField is a type-ahead UITextField. As you type it searches a data source, and it
adds bubbles into the flow of text when you choose a type-ahead option. I use this in
TTMessageController for selecting the names of message recipients.
At a minimum the source code might give you some pointers on how to achieve the various visual effects.
Okay, I've got the shadow working underneath the UITextField, and I've added the "To:" label to it. It looks great!
So the final thing is the blue NSToken like control. I've started to think the easiest thing is just to subclass a UIView and draw the blue gradient and label inside it. Which brings me to some more questions:
I found this: http://github.com/leonho/iphone-libs/tree/master which draws a nice rounded view and I've adapted it to add some text to it rather than a number, what I don't know how to do is draw a gradient instead of a solid block of colour.
After that there's just the matter of adding the rounded views to the UITextField, moving the cursor and working out how to delete the views when the cursor reaches them, but I'll tackle that when I need to.