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]; } } } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。