【发布时间】:2017-12-09 08:44:45
【问题描述】:
我在 UIPopoverController 中嵌入了一个 UITableView,如下所示。
当我选择一个单元格时,单元格中的 textField 变为 firstResponder。但不是保持表格视图滚动到顶部,而是所有内容都消失了(即使不超过 4 个单元格)。如果发生这种情况,滚动到顶部是不可能的。关闭键盘后一切正常。
以下代码不能解决问题:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CRShoppingListItemCell *cell = (CRShoppingListItemCell *) [tableView cellForRowAtIndexPath:indexPath];
cell.itemTextField.enabled = YES;
cell.itemTextField.delegate = self;
[cell.itemTextField becomeFirstResponder];
[tableView scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionNone animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
【问题讨论】:
-
你的 tableView 的 resizingMask 是多少?
-
UIViewAutoresizingFlexibleHeight
标签: ios uitableview uipopovercontroller