The modal dialog box moves up when the keyboard appears and moves down when the keyboard disappears.
Everything is fine until I turn the iPad. In any orientation other than the standard, it does not work. When the iPad rotates, the modal dialog moves down when the keyboard appears instead of up and up, when the keyboard disappears rather than down.
This is the code that I use to position the modal dialog when the 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); } }]; }
user2290869
source share