简体   繁体   中英

Tap Gesture To Dismiss Keyboard Seems To Disables didSelectRow

I have added the following code to my viewDidLoad

UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc]
                                           initWithTarget:self
                                           action:@selector(hideKeyBoard)];

[self.view addGestureRecognizer:tapGesture];

and this somewhere within my .m file as well

-(void)hideKeyBoard {
    [theEditableTextField resignFirstResponder];
    [theEditableTextView resignFirstResponder];


}

Which works fine for dismissing the keyboard when tapping outside of the textfield/view BUT i have added a table view and i need to be able to select a town and i cannot select a row with this code.

How can i disable the keyboard when tapping outside of a textfield or textview but still be able to use didSelectRow for the table view?

这似乎可以解决问题

tapGesture.cancelsTouchesInView = NO;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM