如何在iOS Obj-C中隐藏触摸UITableView上的键盘 [英] How to hide keyboard on touch UITableView in iOS Obj-C

查看:55
本文介绍了如何在iOS Obj-C中隐藏触摸UITableView上的键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发的新手.在TextField之外点击时,我想隐藏键盘.我的TextFieldUITableView的单元格中.

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--

在UITextField之外的任何地方关闭触摸键盘

通过触摸UITableView的背景来关闭键盘

滚动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];
}

这篇关于如何在iOS Obj-C中隐藏触摸UITableView上的键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆