首页 > 代码库 > IOS 回收键盘通用代码

IOS 回收键盘通用代码

感觉IOS的键盘回收好累,所以封装了一个通用一点的方法

-(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];            }        }    }}

 

IOS 回收键盘通用代码