Question

I am using the keyboard type Number Pad for a particular Text Field which is to be given with a zip number. When using regular keyboard i use resignfirstresponder to quit the keyboard when i click on the enter key in that keyboard. But for the number pad, other than numbers there is only a backspace key. So is there a way to customize it or some other technique to resign the number pad?

Was it helpful?

Solution

Plenty of answers are available for this question.

Use dismissing Number Pad or How to dismiss number pad keyboard by tapping anywhere

You can implement which way you like.

OTHER TIPS

You can refer this post for hiding the number pad when tapping on your view or you may refer this for another solution by adding done button on UINavigationBar.

you have 2 ways to do this:

  1. As soon as u show the numPad, add a 'Done' button on tha navigationBar on tap of which you resign the keyboard and remove this 'Done' button from Navigation Bar.

  2. Add a toolBar on top of keyboard for a NumberPad and add a Done button on top of this toolbar. Set the origin of this toolBar (0,maxScreenheight), and on display of the keyboard, change the origin of this toolbar to (0, maxScreenHeight-keyboardHeight-ToolBarHeight) with animationDuration of 0.3. On dismiss of the keyboard change the origin of the toolBar back to (0,maxScreenheight). by doing this the toolbar will look like a part of the keyboard as the animaion duration of the keyboard is 0.3.

you can do so when user touch the screen anywhere the keyboard will dismiss.Here is the code:-

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
    [yourtextFieldName resignFirstResponder];// This will dismiss your keyBoard.
}

and must call UITextField Delegate. If you want to customise the keyboard here is the link which can help you out:-

http://code4app.net/category/keyboard

Hope this will help you out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top