When we develop the user interface, the last few conditions are often easy to be obscured by the system pop-up keyboard, for example:
Can see, mailbox conditions are blocked out, how to solve it? I calculated the offset by the agent of Uitextfield:
-(void) viewdidload{[Super viewdidload];//do no additional setup after loading the view, typically from a nib. Self.emailTextField.delegate = self;} -(void) textfielddidbeginediting: (Uitextfield *) textfield{//1. Frame CGRect frame = Self.emailt to get the blocked mailbox TextField Extfield.frame; 2. Calculate the height (y-coordinate) of the bottom represented by the occluded TextField and the maximum height (y-coordinate) that can not be obscured by the keyboard int offset = FRAME.ORIGIN.Y + +-(self.view.frame.size . height-216); [UIView animatewithduration:0.3 animations:^{if (Offset > 0) {//Let the entire view offset the gap upward Self.view.frame = CGRectMake (0,-offset, Self.view.frame.size.width, self.view.frame.size.height); } }]; }-(void) textfielddidendediting: (Uitextfield *) textfield{[UIView animatewithduration:0.3 animations:^{ After editing is reset to the original Self.view.frame = CGRectMake (0, 0, self.view.frame.size.width, self.view.frame.size.height); }];}Result diagram:
iOS development edit box is ejected by the system soft keyboard occlusion problem