1.添加tap手勢
self.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerTapped:)];
[self.view addGestureRecognizer:singleTap];
-(void)fingerTapped:(UITapGestureRecognizer *)gestureRecognizer
{
[self.view endEditing:YES];
}
2.調動touchesBegan方法
2.1.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.telTextField resignFirstResponder];
}
2.2
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
}