9
In my quest for my first iPhone app I have posted about the correct way to handle the return key on the iOS keyboard. Now I need to figure out the toolbar above the keyboard with prev/next and done buttons. I have been working with an example from the following site: Input Accessory View
The example works, but I want to use a UIToolbar and UIBarButtonItem's instead of just a regular view with buttons. I have tried various combinations, none work yet. Here is what I have so far.
Header:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITextFieldDelegate>
{
UITextField* txtActiveField;
UIToolbar* keyboardToolbar;
UIBarButtonItem* btnDone;
UIBarButtonItem* btnNext;
UIBarButtonItem* btnPrev;
}
@property (nonatomic, strong) IBOutlet UITextField* firstNameTextField;
@property (nonatomic, strong) IBOutlet UITextField* lastNameTextField;
@property (nonatomic, strong) IBOutlet UITextField* cityTextField;
@property (nonatomic, strong) UITextField* txtActiveField;
@property (nonatomic, strong) UIToolbar* keyboardToolbar;
@property (nonatomic, strong) UIBarButtonItem* btnDone;
@property (nonatomic, strong) UIBarButtonItem* btnNext;
@property (nonatomic, strong) UIBarButtonItem* btnPrev;
-(void)createInputAccessoryView;
@end
Source:
#import "ViewController.h"
@implementation ViewController
@synthesize firstNameTextField = _firstNameTextField;
@synthesize lastNameTextField = _lastNameTextField;
@synthesize cityTextField = _cityTextField;
@synthesize txtActiveField = _txtActiveField;
@synthesize keyboardToolbar = _keyboardToolbar;
@synthesize btnDone = _btnDone;
@synthesize btnNext = _btnNext;
@synthesize btnPrev = _btnPrev;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - View lifecycle
- (voi