iOS键盘按下完成和点击空白处隐藏软键盘

-(void)viewDidLoad

{

self.view.userInteractionEnabled = YES;

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerTapped:)];

[self.view addGestureRecognizer:singleTap];

}

-(BOOL) textFieldShouldReturn:(UITextField *)textField {

[textField resignFirstResponder];

return YES;

}

-(void)fingerTapped:(UITapGestureRecognizer *)gestureRecognizer

{

[self.view endEditing:YES];

}原文

你可能感兴趣的:(iOS键盘按下完成和点击空白处隐藏软键盘)