[英]Tap Gesture To Dismiss Keyboard Seems To Disables didSelectRow
I have added the following code to my viewDidLoad 我已将以下代码添加到我的viewDidLoad中
UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(hideKeyBoard)];
[self.view addGestureRecognizer:tapGesture];
and this somewhere within my .m file as well 以及我的.m文件中的某个位置
-(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? 在文本框或文本视图之外点击但如何仍能对表视图使用didSelectRow时,如何禁用键盘?
这似乎可以解决问题
tapGesture.cancelsTouchesInView = NO;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.