作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 iPad 编程的新手,我想知道如何从 UItablecell 中定义的 UItextview 中关闭键盘。我在单元格中定义了多个 TextView 。请帮助我提出适当的解决方案或您的建议。
最佳答案
发送文本查看消息 resignFirstResponder
键盘将消失。如果您需要关闭它以响应返回键,请考虑让您的 View Controller 采用 UITextViewDelegate
协议(protocol)。
[self.textViewInQuestion resignFirstResponder];
或者,您可以像这样将 endEditing:
消息发送到 TableView :
/*
Attempt to resign first responder status on any textfields within
the view's hierarchy.
*/
[self.tableView endEditing:NO];
// OR we can....
/*
Force text fields within the view's hierarchy to resign first responder.
Textfield delegates cannot prevent this from happening so this is not
recommended if you need to perform field validation and prevent the user
from leaving the textfield.
However sometimes it is useful to be able to force the resignation of the
first responder status even with validation so it goes both ways really.
*/
[self.tableView endEditing:YES];
关于ipad - 如何从 iPad 的 UITableview 中定义的 UITextview 中关闭键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12968020/
我是一名优秀的程序员,十分优秀!