感覺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]; } } } }