0

我在 IB 中是静态的UITableView,当我单击单元格时,我想隐藏键盘。什么时候isFirstResponderUITextField!但是当UITextView它不起作用时:(

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [publicationTextView resignFirstResponder];
    //[self.view endEditing:YES];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
4

1 回答 1

0

如果您想隐藏文本字段的键盘,请尝试在将子视图添加到单元格时将 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];


// 希望这可以帮助

于 2013-08-12T05:35:37.697 回答