When we develop the registration interface, the last few registration conditions are often easily blocked by the system pop-up keyboard, such:
As you can see, the mailbox condition is blocked. How can this problem be solved? I calculated the offset using the UITextField Proxy:
-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self. emailTextField. delegate = self;}-(void) textFieldDidBeginEditing :( UITextField *) textField {// 1. get the frame CGRect frame = self of textField of the blocked mailbox. emailTextField. frame; // 2. calculate the distance between the height (Y coordinate) represented by the bottom of the masked textField and the maximum height (Y coordinate) not blocked by the keyboard. int offset = frame. origin. y + 32-(self. view. frame. size. height-216); [UIView animateWithDuration: 0.3 animations: ^ {if (offset> 0) {// Let the entire view offset up to 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, reset it to the original self. view. frame = CGRectMake (0, 0, self. view. frame. size. width, self. view. frame. size. height);}];}Result chart: