首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UITextView resignFirstResponder on didSelectRowAtIndexPath

UITextView resignFirstResponder on didSelectRowAtIndexPath
EN

Stack Overflow用户
提问于 2013-08-11 20:14:07
回答 1查看 366关注 0票数 0

我有IB静态UITableView,当我单击单元格时,我想隐藏键盘。当isFirstResponderUITextField的时候,就好了!但是当UITextView不起作用时:

代码语言:javascript
复制
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [publicationTextView resignFirstResponder];
    //[self.view endEditing:YES];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-12 05:35:37

如果要隐藏文本字段的键盘,请在向单元格i,e中添加子视图时,尝试将isEditable设置为"NO“。

代码语言:javascript
复制
     //- (UITableViewCell *)tableView:(UITableView *)tableView   cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    UITextView *aTv = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, 200, 300)];
    aTv.text = @"textView";
    aTv.delegate = self;
    [aTv setEditable:NO]; //avoid appearing of key board when tap on the text field
    [cell addSubview:aTv];

//希望这有帮助

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18176231

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档