如何在iOS Obj-C中隐藏触摸UITableView上的键盘 [英] How to hide keyboard on touch UITableView in iOS Obj-C
本文介绍了如何在iOS Obj-C中隐藏触摸UITableView上的键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是iOS开发的新手.在TextField
之外点击时,我想隐藏键盘.我的TextField
在UITableView
的单元格中.
I am new in iOS development. I want to hide the keyboard when tapping outside of a TextField
. My TextField
is in a cell from an UITableView
.
我尝试跟踪其中一些链接,但是没有成功-
I have tried to follow some of those links, however without any success--
我正在尝试找到最简单的方法. 预先感谢
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];
}
这篇关于如何在iOS Obj-C中隐藏触摸UITableView上的键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文