Several methods of IOS click on the blank space to hide the keyboard

 

Create a custom touch gesture to hide the keyboard:

 

- (void)viewDidLoad  
{  
    [super viewDidLoad];  
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];  
    //Set to NO to indicate that the current control will propagate to other controls after the response, the default is YES.  
    tapGestureRecognizer.cancelsTouchesInView = NO;  
    //Add touch event to current view  
    [self.view addGestureRecognizer:tapGestureRecognizer];  
}  
  
-(void)keyboardHide:(UITapGestureRecognizer*)tap{  
    [textFiled resignFirstResponder];  
}  

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326639070&siteId=291194637