Eric Eric - 1 year ago 73
iOS Question

How to hide keyboard on touch UITableView in iOS Obj-C

I am new in iOS development. I want to hide the keyboard when tapping outside of a

. My
is in a cell from an

I have tried to follow some of those links, however without any success--

Dismiss keyboard on touch anywhere outside UITextField

Dismiss keyboard by touching background of UITableView

Hide keyboard when scroll UITableView

I am trying to find the simplest way possible.
Thanks in advance


This is the simplest way to dismiss keyboard

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
    [tableView addGestureRecognizer:gestureRecognizer];
- (void)hideKeyboard
    [self.view endEditing:YES];