'How to create Previous/Next buttons above keyboard like in Safari

I'm trying to add Previous/Next buttons above the keyboard like in mobile Safari. There are a lot of questions about that here on StackOverflow, but most answers are to use inputAccessoryView. I tried that and it looks like this:

My app

Is there anyway to have the buttons in the toolbar bellow, like it works in mobile Safari??

This is how it looks like in Safari:

Mobile Safari



Solution 1:[1]

It seems what I was looking for is inputAssistantItem.

It allows you to add and change buttons in the keyboard's shortcut bar.

UIBarButtonItem* nextButton = [[UIBarButtonItem alloc]
                               initWithImage:nextImage
                               style:UIBarButtonItemStylePlain
                               target:self
                               action:@selector(nextField:)];
UIBarButtonItem* previousButton = [[UIBarButtonItem alloc]
                                   initWithImage:previousImage
                                   style:UIBarButtonItemStylePlain
                                   target:self
                                   action:@selector(previousField:)];
NSArray *buttonGroups = @[[[UIBarButtonItemGroup alloc]
                           initWithBarButtonItems:@[previousButton, nextButton]
                           representativeItem:nil]];

textField.inputAssistantItem.trailingBarButtonGroups = buttonGroups;

Solution 2:[2]

UIBarButtonItem *previous = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:103  target:self action:@selector(previousButtonTapped:)];
UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[fixedSpace setWidth:6.0];
UIBarButtonItem *next = [[UIBarButtonItem alloc]  initWithBarButtonSystemItem:104 target:self action:@selector(nextButtonTapped:)];

toolbar with previous/next bar button items

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andres
Solution 2 CyberMoai