IOS development-Disable/collapse keyboard method summary, ios collapse

Source: Internet
Author: User

IOS development-Disable/collapse keyboard method summary, ios collapse

As IOS developers, they often need to deal with forms. Therefore, I have summarized the keyboard collapse method. There are three methods for IOS to collapse the keyboard (if there are other ways to collapse the keyboard, please refer to the error in the message area ).

 

1. Click Return to collapse the keyboard

-(BOOL) textFieldShouldReturn :( UITextField *) textField {return [textField resignFirstResponder];}

 

2. Click the background View to collapse the keyboard (your View must inherit from UIControl)

[Self. view endEditing: YES];

 

3. You can add this sentence anywhere to fold the keyboard

[[[UIApplication sharedApplication] keyWindow] endEditing: YES];

I met this method not long ago. I wrote it down when I thought it was useful.

 

Blog Author: GarveyCalvin

Blog Source: http://www.cnblogs.com/GarveyCalvin/

The copyright of this article is shared by the author and the blog. You are welcome to repost it, but you must keep this statement and provide the original article link. Thank you for your cooperation!

 

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.