There is UITextField under ios UIView. The keyboard pops up to affect the content of the input TextField. solution:

Source: Internet
Author: User

Set the tag for each TextField during viewdidload. Then you can determine the pop-up and off of the keyboard based on the following UITextField content.

Some TextField * names

Name. tag = 2;

The following figure shows that when tag = 2, the interface can be mentioned above.

-(Void) textFieldDidBeginEditing :( UITextField *) textField

{// This method is called when you click inside textField to start editing. TextField will become first responder

If (textField. tag = 2 ){

NSTimeInterval animationDuration = 0.30f;

CGRect frame = self. view. frame;

Frame. origin. y-= 216;

Frame. size. size + = 216;

Self. view. frame = frame;

[UIViewbeginAnimations: @ "ResizeView" context: nil];

[UIView setAnimationDuration: animationDuration];

Self. view. frame = frame;

[UIViewcommitAnimations];

}

}

 

-(BOOL) textFieldShouldReturn :( UITextField *) textField

{// When the user presses ruturn and removes the focus from textField, the keyboard disappears.

// TextField

If (textField. tag = 2 ){

NSTimeInterval animationDuration = 0.30f;

CGRect frame = self. view. frame;

Frame. origins. y + = 216;

Frame. size. height = 216;

Self. view. frame = frame;

// Self. view

[UIViewbeginAnimations: @ "ResizeView" context: nil];

[UIView setAnimationDuration: animationDuration];

Self. view. frame = frame; www.2cto.com

[UIViewcommitAnimations];

}

[TextField resignFirstResponder];

ReturnYES;

}

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.