我有IB静态UITableView,当我单击单元格时,我想隐藏键盘。当isFirstResponder是UITextField的时候,就好了!但是当UITextView不起作用时:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[publicationTextView resignFirstResponder];
//[self.view endEditing:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}发布于 2013-08-12 05:35:37
如果要隐藏文本字段的键盘,请在向单元格i,e中添加子视图时,尝试将isEditable设置为"NO“。
//- (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];//希望这有帮助
https://stackoverflow.com/questions/18176231
复制相似问题