I have a view like you can see over here. 
You can see that I have an header image with below a lot of textfields. Only the UITextfields Adres - Postcode - Gemeente - Tel.nr - Email - BTWnr. are disappearing behind the keyboard. I have some code, that is working for the UITextfield of Adres. But when I want to implement more it always takes the animation for the UITextfield of Adres.
Here is what I have in code
#define kOFFSET_FOR_KEYBOARD 80.0 #define kOFFSET_FOR_KEYBOARD2 120.0 -(void)keyboardWillShow { NSLog(@"Keyboard frame now is %f",self.keyboardView.frame.origin.y); // Animate the current view out of the way if (self.keyboardView.frame.origin.y >= 198) { NSLog(@"keyboardWillShow 1"); [self setViewMovedUp2:NO]; } else if (self.keyboardView.frame.origin.y < 198) { NSLog(@"keyboardWillShow 2"); [self setViewMovedUp:YES]; } } -(void)keyboardWillHide { NSLog(@"Keyboard frame ATM %f",self.keyboardView.frame.origin.y); if (self.keyboardView.frame.origin.y >= 198) { NSLog(@"keyboardWillHide 1"); [self setViewMovedUp:YES]; } else if (self.keyboardView.frame.origin.y < 198) { NSLog(@"keyboardWillHide 2"); [self setViewMovedUp:NO]; } } -(void)textFieldDidBeginEditing:(UITextField *)sender { if ([sender isEqual:txtAdres]) { NSLog(@"sender is adres"); //move the main view, so that the keyboard does not hide it. if (self.keyboardView.frame.origin.y >= 198) { [self setViewMovedUp:YES]; } } if ([sender isEqual:txtPostcode]) { NSLog(@"sender is postcode"); //move the main view, so that the keyboard does not hide it. if (self.keyboardView.frame.origin.y >= 198) { [self setViewMovedUp2:YES]; } } } //method to move the view up/down whenever the keyboard is shown/dismissed -(void)setViewMovedUp:(BOOL)movedUp { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; // if you want to slide up the view CGRect rect = self.keyboardView.frame; if (movedUp) { // 1. move the view's origin up so that the text field that will be hidden come above the keyboard // 2. increase the size of the view so that the area behind the keyboard is covered up. rect.origin.y -= kOFFSET_FOR_KEYBOARD; rect.size.height += kOFFSET_FOR_KEYBOARD; } else { // revert back to the normal state. rect.origin.y += kOFFSET_FOR_KEYBOARD; rect.size.height -= kOFFSET_FOR_KEYBOARD; } self.keyboardView.frame = rect; [UIView commitAnimations]; } -(void)setViewMovedUp2:(BOOL)movedUp { NSLog(@"setViewMovedUp2 called"); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; // if you want to slide up the view CGRect rect = self.keyboardView.frame; if (movedUp) { // 1. move the view's origin up so that the text field that will be hidden come above the keyboard // 2. increase the size of the view so that the area behind the keyboard is covered up. rect.origin.y -= kOFFSET_FOR_KEYBOARD2; rect.size.height += kOFFSET_FOR_KEYBOARD2; } else { // revert back to the normal state. rect.origin.y += kOFFSET_FOR_KEYBOARD2; rect.size.height -= kOFFSET_FOR_KEYBOARD2; } self.keyboardView.frame = rect; [UIView commitAnimations]; } And in my ViewWillAppear I do this
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil]; Can anybody help me with this ?