There is an easier way to do this.
Keep notification on keyboard in viewDidLoad
After that, you will need the following method:
-(void)keyboardDidShow:(NSNotification*)notif { NSArray *array = [[UIApplication sharedApplication] windows]; for (UIWindow* wind in array) { for (UIView* currView in wind.subviews) { if ([[currView description] hasPrefix:@"<UIPeripheralHostView"]) { for (UIView* perView in currView.subviews) { if ([[perView description] hasPrefix:@"<UIWebFormAccessory"]) { UIBarButtonItem *doneBttn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(resignKeyBoard)]; NSMutableArray *arr = [[NSMutableArray alloc] initWithArray: [(UIToolbar *) perView items]]; [arr addObject:doneBttn]; [(UIToolbar *) perView setItems:arr]; } } } } } }
Basically, I took the original previous / next buttons from UIWebFormAccessory and added the Finish button to the end, but you can add whatever you want for this.
Some might think that this should not be implemented in -(void)keyboardDidShow: because you change the user interface after it appears on the screen, but so far I have not noticed any problems with this. (tested only in the simulator)
Hope this was helpful!
Jlau_cy
source share