The modal dialog gets moved up when they keyboard appears and moves down when the keyboard disappears.
All is fine till I rotate the iPad. In any other orientation except the standard it doesn't work. When the iPad is turned around the modal dialog moves down when the keyboard appears instead of up and up when the keyboard disappears instead of down.
This is the code I am using to position the modal dialog when keyboard appears/disappears.
- (void)textFieldDidBeginEditing:(UITextField *)textField {
self.view.superview.frame = CGRectMake(self.view.superview.frame.origin.x, 140, self.view.superview.frame.size.width, self.view.superview.frame.size.height);
}
}];
}
-(void)textFieldDidEndEditing:(UITextField *)textField {
[UIView animateWithDuration:0.4 animations:^ {
self.view.superview.frame = CGRectMake(self.view.superview.frame.origin.x, 212, self.view.superview.frame.size.width, self.view.superview.frame.size.height);
}
}];
}
You should try using Keyboard Notifications:
and then in the selectors adjust the frame. Not in textFieldDidBeginEditing/textFieldDidEndEditing.
Instead of setting the frame, use CGAffineTransformTranslate, for example like so: