IOS Keyboard Masking textfiled Issues

Source: Internet
Author: User

1. Add delegate,2. Set a delegate, 3. Implement the following 3 methods:

When you start editing the input box, the soft keyboard appears, performing this event

-(void) textfielddidbeginediting: (Uitextfield *) TextField

{

CGRect frame = textfield.frame;

int offset = FRAME.ORIGIN.Y +-(self.view.frame.size.height-216.0);//Keyboard Height 216

Nstimeinterval animationduration = 0.30f;

[UIView beginanimations:@ "Resizeforkeyboard" context:nil];

[UIView setanimationduration:animationduration];

Move the y-coordinate of the view up to offset units so that the space below is used for the display of the soft keyboard

if (Offset > 0)

Self.view.frame = CGRectMake (0.0f,-offset, Self.view.frame.size.width, self.view.frame.size.height);

[UIView commitanimations];

}

Keyboard disappears when the user presses return or presses the ENTER key

-(BOOL) Textfieldshouldreturn: (Uitextfield *) TextField

{

[TextField Resignfirstresponder];

return YES;

}

Restore the view to its original state when the input box is finished editing

-(void) textfielddidendediting: (Uitextfield *) TextField

{

Self.view.frame =cgrectmake (0, Self.view.frame.size.width, self.view.frame.size.height);

}

IOS Keyboard Masking textfiled issues

Related Article

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.