How to add button on numeric Keyboard in iOS

Asked

Viewed 218 times

1

I’m developing an app that on one of the screen there are only two UITextField, an alphanumeric and a numeric. Here comes my problem, Keyboard alpha has the Return/next button, but Keyboard numeric has no.

Initially my idea would be to disable the alphanumeric Keyboard’s Return/next button and include a small bar on top of the keyboards with two fields, a next and a Previous for navigation. But I have been told that this does not follow the standard of usability.

I have how to include a "Next" button in the blank next to the 0 key of the numeric Keyboard?

  • some version of iOS specifies?

  • Man, I’m using the very latest version

1 answer

4


You can use the following library:

https://github.com/broderboy/iphone-DoneCancelNumberPadToolbar

The idea is to create a Toolbar at the top of the number pad with the "OK" or "Cancel".

You can also add directly via code:

UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
numberToolbar.barStyle = UIBarStyleBlackTranslucent;
numberToolbar.items = [NSArray arrayWithObjects:
                     [[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelNumberPad)],
                     [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                     [[UIBarButtonItem alloc]initWithTitle:@"Apply" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)],
                 nil];
[numberToolbar sizeToFit];
numberTextField.inputAccessoryView = numberToolbar;

This code was taken from the same answer via Stackoverflow in English, but works normally.

https://stackoverflow.com/questions/584538/how-to-show-button-done-on-number-pad-on-iphone

  • Wow Julio, so far so good! rs But that doesn’t take away my initial problem of alpha Keyboard getting the next/Return button and numerical Keyboard not having... My idea was to either leave both keyboards without.... or leave the two with... then I believe that in my case it is necessary to include the next button in the same numerical Keyboard...

  • Julio, in the same answer has this link below which is what I was looking for. So I’ll test to see if it works, vlws! http://www.neoos.ch/blog/37-uikeyboardtypenumberpad-and-the-missing-return-key

  • Great David. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.