views:

1150

answers:

4

Currently I have a textfield, which pulls up a NumberPad keyboard for input.

I want the NumberPad keyboard layout, but I need a button to resign that responder.

Is there a way to code the UITextField so that it has a NumberPad keyboard and the space on the left of the keyboard which is blank is replaced with a 'Done', 'Send' or 'Go' button.

Or do I need to create a custom inputView for the UITextField?

I would have thought since there is a blank key on the NumberPad apple would have made it useful for something.

+1  A: 

Duplicate question, please look at here

Here is a link to a way to create such a button

vodkhang
Those techniques stopped working in iOS 4.
Will Harris
Oh, really? I didn't try with iOS4. I will test it soon
vodkhang
My mistake! The technique does work, but modifying the keyboard must be done from UIKeyboardWillShowNotification. I was using textFieldDidBeginEditing:, which is called too early in 4.0.
Will Harris
Ah yeah, but using this kind of technique is not really 100% guarantee, anyway.
vodkhang
I just took a look at the Contacts application on my Ipod. They also put a button there, so if we do the button in correct way, I don't think it may have problems
vodkhang
I wasnt able to get the sample code from that link to work. would some body be able to post a working version?
OscarTheGrouch
http://files.neoos.ch/KeyboardExtension.zip You can download it from here
vodkhang
I downloaded that file... is there any code that needs to be changed? It doesn't seem to work straight from the download. Im running the latest iOS 4.0 sdk.
OscarTheGrouch
Did you try on iphone simulator 3.1 or 3.2? My trying was with 3.1
vodkhang
Got it working on iOS 4, see the linked duplicate question: http://stackoverflow.com/questions/3014964/how-to-show-button-done-on-number-pad-on-iphone-os-4/3127256#3127256
Henrik N
working sample code. http://dl.dropbox.com/u/8256776/KeyboardAccessory.zip
OscarTheGrouch
A: 

You need to do a custom inputview now and assign it to the inputview property of your text field. I am currently researching it, but that is the right, approved way of doing it. It seems overkill just for changing a single button though.

Julian
http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-keyhas updated content for iOS4.0
OscarTheGrouch
A: 

Does anyone have a comprehensive example with multiple text fields (preferably of different keyboard types too) that they can link to or post up?

I've tried 3 times from scratch now and can cannot get it working without various crashes :( It doesn't help that the best example Apple have is using NSNotification instead of the UITextFieldDelegate protocol!

Thanks

OOP_Master