you must implement the following method
- (BOOL) textFieldShouldBeginEditing:(UITextField *)textField{ [self adjustFramesWhenKeyoradIsShown]; }
in the implementation, you must adjust the text box frame. if you have other views that you want to show, as well as not hidden on the keyboard, you should also move them. It is useful to have two methods that reconfigure frames for two positions (one when the keyboard is displayed, and one when it is hidden, therefore, as soon as editing the text field is edited, you call another method in the following delegation method of the text field:
- (BOOL)textFieldShouldReturn:(UITextField *)textField { [self adjustFramesWhenKeyoradIsHidden]; }
in these two help methods you change the position of the frame and change the view to be hidden or not, it will look better if you revive them, something like this:
- (void) adjustFramesWhenKeyoradIsShown{ [UIView animateWithDuration:0.3 delay:0.0 options: UIViewAnimationCurveEaseOut animations:^{ logoArea.hidden = YES; loginFieldsArea.frame = CGRectMake(0, 0, 320, 250); } completion:^(BOOL finished){ }]; }
source share