我的视图中有一个 tableView 并且一切正常,但是每个自定义单元格 (ToDoListCell) 都有一个文本字段,我允许用户编辑、更新他们的数据。一切都很好,每当尝试滚动到将被键盘隐藏的单元格时,都会出现我的问题。
注意:我按照 Apple 文档的建议使用 NSNotificationCenter 观察者方法调整表的大小,我知道这不是问题。
- (void)scrollToSelectedCell {
NSIndexPath *currentIndexPath = [NSIndexPath indexPathForItem:0 inSection:0];
while (currentIndexPath.row < self.todos.count) {
ToDoListCell *cell = (ToDoListCell *)[self.table cellForRowAtIndexPath:currentIndexPath];
if (cell.titleField.isEditing == YES) {
[self.table scrollToRowAtIndexPath:currentIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
break;
}
currentIndexPath = [NSIndexPath indexPathForItem:currentIndexPath.row + 1 inSection:0];
}
}
知道为什么它不会滚动到当前不在屏幕上的任何单元格吗?
谢谢,
本