below you\'ll find my .h & .m files for my primary viewcontroller.
I have 3 questions.
1.) Because I have multiple uitextfields, do I have to set each with
Here's what I use in my code. It works great and is more efficient than the other answers.
In yourviewcontroller.h add:
@property (nonatomic) UITapGestureRecognizer *tapRecognizer;
Now in the .m file, add this to your ViewDidLoad function:
- (void)viewDidLoad {
//Keyboard stuff
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapAnywhere:)];
tapRecognizer.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:tapRecognizer];
}
Also, add this function in the .m file:
- (void)handleSingleTap:(UITapGestureRecognizer *) sender
{
[self.view endEditing:YES];
}