我是iPad编程的新手,我想知道如何从UItablecell中定义的UItextview中解除键盘。我在单元格中定义了多个textview。请帮助我找到你身边的正确解决方案或建议。
答案 0 :(得分:1)
向文本视图发送消息resignFirstResponder
,键盘将解除。如果您需要将其关闭以响应返回键,请查看视图控制器是否采用UITextViewDelegate
协议。
[self.textViewInQuestion resignFirstResponder];
或者,您可以将endEditing:
消息发送到表格视图,如下所示:
/*
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];