On viewDidLoad add the following lines:
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
[self.view addGestureRecognizer:gestureRecognizer];
Then add the following function somewhere in the implementation file.
- (void) hideKeyboard {
[activeField resignFirstResponder];
}
Here activeField is an UITextField object. Declare it somewhere at the top of the view controller's implementation file.
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
[self.view addGestureRecognizer:gestureRecognizer];
Then add the following function somewhere in the implementation file.
- (void) hideKeyboard {
[activeField resignFirstResponder];
}
Here activeField is an UITextField object. Declare it somewhere at the top of the view controller's implementation file.
No comments:
Post a Comment