【发布时间】:2017-12-07 00:10:27
【问题描述】:
我在 UITableViewCell 中有一个 UITextView。我已将其设置为在选择单元格时成为第一响应者:
TPNTableViewCell *thisCell = (TPNTableViewCell *)[tblMain cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
thisCell.txtHidden.text=@"";
[thisCell.txtHidden becomeFirstResponder];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goAwayKeyboard)];
[self.view addGestureRecognizer:tap];
所以当单元格被选中时,txtHidden 成为第一响应者。然后当您单击键盘外时会触发选择器 goAwayKeyboard。
-(void)goAwayKeyboard
{
TPNTableViewCell *thisCell = (TPNTableViewCell *)[tblMain cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
[thisCell.txtHidden resignFirstResponder];
}
这可行,但是在键盘退出后,我无法再选择表格视图中的单元格。我可以滚动表格视图,但无法选择单元格,我不知道为什么。
【问题讨论】:
标签: ios objective-c uitableview