How to add button on numeric keyboard in iOS

1

I'm developing an app that on one of the screen there is only two UITextField , one alphanumeric and one numeric. If you have a problem, the keyboard alpha has the return / next button, but the numeric keypad does not.

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 one for navigation. But I've been told here that this does not follow the usability standard.

Can I add a "Next" button in the blank space next to the numeric keypad's 0 key?

    
asked by anonymous 18.02.2014 / 00:09

1 answer

4

You can use the following library:

link

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

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 response via StackOverflow in English, but it works normally.

link

    
18.02.2014 / 01:56