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 keyboar
I have managed to use your code in my current project with the addition of adding the toolbar on top of a UIDatePicker that gets initiated by a textfield inside a UITableView. I'm using static cells.
It works for me.
I have the UITextFields as IBOutlets and only use this code to set the InputAccessoryView
[textFieldName setInputAccessoryView:self.keyboardToolbar];
[textFieldEmail setInputAccessoryView:self.keyboardToolbar];
[textFieldPhone setInputAccessoryView:self.keyboardToolbar];
[textFieldDate setInputAccessoryView:self.keyboardToolbar];
[textFieldSize setInputAccessoryView:self.keyboardToolbar];
Well, the next and prev buttons work like a charm (but only on the way down the table). I still had to manually scroll the table to the top when going back up. For some reason the UITableViewController only handles the scrolling down scenario, which I found quite odd, but here is my code snippet for previous.
- (void) gotoPrev {
if (self.activeField == textFieldName) { // name --> nowhere
return;
}
else if (self.activeField == textFieldEmail) { // email --> name
[textFieldName becomeFirstResponder];
}
else if (self.activeField == textFieldPhone) { // phone --> email
[textFieldEmail becomeFirstResponder];
// Scroll jeegar
NSIndexPath * myIndexPath= [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView scrollToRowAtIndexPath:myIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
else if (self.activeField == textFieldDate) { // date --> phone
[textFieldPhone becomeFirstResponder];
}
else if (self.activeField == textFieldSize) { // people --> date
[textFieldDate becomeFirstResponder];
}
}