iOS Development-closing/collecting keyboard methods Summary

Source: Internet
Author: User

As an iOS developer, you often need to work with forms. So I summed up the way the keyboard was picked up, iOS has three ways to close the keyboard (if there are other ways to pick up the keyboard, make a mistake in the message area).

1. Close the keyboard when you click return button

-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{    return  [TextField Resignfirstresponder];}

2. Click on the background view to close the keyboard (your view must be inherited from Uicontrol)

[Self.view Endediting:yes];

3, you can add this sentence anywhere, can be used to unify the keyboard

[[[UIApplication sharedapplication] Keywindow] endediting:yes];

This method I met recently, feel useful, it is written down.

Blog Garveycalvin

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

This article copyright belongs to the author and the blog Garden altogether, welcome reprint, but must retain this paragraph statement, and gives the original link, thanks cooperation!

iOS Development-closing/collecting keyboard methods Summary

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.