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!