General keyboard recycling code for IOS and keyboard recycling code for ios

Source: Internet
Author: User

General keyboard recycling code for IOS and keyboard recycling code for ios

I feel tired of Using IOS keyboards, So I encapsulated a general method.

-(IBAction)spbResignFirstResponder:(id)sender{    //    NSLogObj(sender);    if (sender == NULL || [sender isKindOfClass:[UITapGestureRecognizer class]]) {        if (self.view != NULL && self.view.subviews != NULL && self.view.subviews.count > 0) {            for (UIView *item in self.view.subviews) {                if ([item isKindOfClass:[UITextField class]] || [item isKindOfClass:[UITextView class]]) {                    UITextField *textField_item = (UITextField *)item;                    [textField_item resignFirstResponder];                }                                [self spbResignFirstResponder:item];            }        }    }else if ([sender isKindOfClass:[UIView class]]) {        UIView *view_item = sender;        if ([view_item isKindOfClass:[UITextField class]] || [view_item isKindOfClass:[UITextView class]]) {            [view_item resignFirstResponder];        }                if (view_item.subviews != NULL && view_item.subviews.count > 0) {            for (UIView *item in view_item.subviews) {                [self spbResignFirstResponder:item];            }        }    }}

 


In iOS development, when the keyboard pops up, what code can be used to obtain the type of the pop-up keyboard?

Register the message [[NSNotificationCenter defaultCenter] addObserver: self selector: @ selector (keyboardWillShown :) name: UIKeyboardWillShowNotification object: nil] displayed on the keyboard;
Then in the message return Method
-(Void) keyboardWillShown :( NSNotification *) aNotification {// The keyboard information dictionary NSDictionary * info = [aNotification userInfo];} You should have enough content in this dictionary, the total height of a keyboard, etc.


How can iOS use code to hit other places on the screen and let the keyboard bounce back?

You mean to hide the keyboard after it comes out, right? You can go to the lazy ios code library to see what you may need... the instance has several combinations of idaozenm ..

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.