- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *gesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(CloseKeyBoard:)];
[self.view addGestureRecognizer:gesture];
}
-(void)CloseKeyBoard:(UITapGestureRecognizer *)gesture{
for (id object in self.view.subviews) {
if ([object isKindOfClass:[UITextField class]]) {
UITextField *textfield=object;
if ([textfield isFirstResponder]) {
[textfield resignFirstResponder];
}
}
}
//[self.view endEditing:YES];
}
时间: 2024-10-10 04:43:39