iOS development edit box is ejected by the system soft keyboard occlusion problem

Source: Internet
Author: User

When we develop the registration interface, the last few registration conditions are often easily obscured by the system pop-up keyboard, such as:


Can see, mailbox conditions are obscured, how to solve it? I calculated the offset by the agent of the 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:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.