- (void)viewDidLoad {
...
[self.view addGestureRecognizer:[[UITapGestureRecognizer alloc]
initWithTarget:self.view
action:@selector(endEditing:)]];
...
}
The same can be re-written with a selector method as follows.
- (void)viewDidLoad {
...
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(hideKeyboard)];
[self.view addGestureRegnizer:tap];
...
}
- (void)hideKeyboard {
[self.view endEditing:YES];
}
No comments:
Post a Comment