IOS回収キーボード共通コード
2487 ワード
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];
}
}
}
}