How to get a keyboard with Next, Previous, and Done buttons?

I want to have a keyboard that has a Next, Previous, and Done button.

I have seen this in many applications.

Especially where there are completed forms.

enter image description here

I want to achieve something similar to the keyboard above.

How can i get this?

+64
iphone cocoa-touch ios4 iphone-keypad
Apr 08 '11 at 7:20
source share
8 answers

You will find the answer to this other post . I checked the iOS library and inputAccessoryView UITextField is exactly what you are looking for!

Hope this helps!

+60
Apr 08 2018-11-11T00:
source share

I just created a class called BSKeyboardControls , which makes it easy to add controls to the keyboard. Class, instructions, and sample code can be found here on GitHub .

The controls work for text fields and text presentations and are optimized for both iPhone and iPad.

+25
Jan 16 '12 at 14:50
source share
 -(BOOL)textFieldShouldBeginEditing: (UITextField *)textField { UIToolbar * keyboardToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; keyboardToolBar.barStyle = UIBarStyleDefault; [keyboardToolBar setItems: [NSArray arrayWithObjects: [[UIBarButtonItem alloc]initWithTitle:@"Previous" style:UIBarButtonItemStyleBordered target:self action:@selector(previousTextField)], [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStyleBordered target:self action:@selector(nextTextField)], [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(resignKeyboard)], nil]]; textField.inputAccessoryView = keyboardToolBar; } - (void)nextTextField { if (textField1) { [textField1 resignFirstResponder]; [textField2 becomeFirstResponder]; } } -(void)previousTextField { if (textField2) { [textField2 resignFirstResponder]; [textField1 becomeFirstResponder]; } } -(void)resignKeyboard { [textField1 resignFirstResponder]; [textField2 resignFirstResponder]; } 
+19
Sep 27 '13 at 14:52
source share

I have a utility class that basically does this for you.

https://github.com/kalvish21/CustomKeyboard

The idea is very simple. You must add an additional toolbar with button elements on it. There is a delegate who determines what this button will do.

+6
10 Oct '12 at 16:10
source share

https://github.com/hackiftekhar/IQKeyboardManager

This is the best keyboard handler I've ever seen. A very great way to control text input.

Some of its features 1) ZERO LINE OF CODE

2) works automatically

3) No more UIScrollView

4) No more subclasses

5) No more handmade

6) No more #import

+4
Dec 21 '14 at 15:35
source share

This is a custom control that sits directly above the keyboard. I think UIToolbar can be used for this.

The previous and next passes around the first Responder of textFields and Done will resign, and also hide the toolbar.

To match keyboard animations, look at this code I found in either SO: "What is the default keyboard animation speed of the iPhone?"

+1
Apr 08 2018-11-11T00:
source share
0
Aug 28 '12 at 11:26
source share

As mentioned in other answers, this is the inputAccessoryView you are looking for.

I would like to add an alternative path here using these cocoapods:

pod ' UITextField-Navigation '

All UITextField will have two additional properties: nextTextField and previousTextField . Then you can simply connect nextTextField in the interface builder, and the Previous, Next, and Finish buttons will be added automatically for you, all functional, no more code required, no subclass.

You can also customize the user interface, add other buttons, etc., as you want.

enter image description here enter image description here

0
Jun 28 '16 at 3:31
source share



All Articles