我在IB静态UITableView
中,当我点击单元格时,我想要隐藏键盘。
当isFirstResponder
为UITextField
时,没关系!
但是当UITextView
不起作用时:(
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[publicationTextView resignFirstResponder];
//[self.view endEditing:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
答案 0 :(得分:0)
如果要隐藏文本字段的键盘,请在将子视图添加到单元格时将设置isEditable设置为“NO” I,E
//- (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];
//希望这有帮助