我一直在努力解决扩展 UITextView
这个非常普遍的问题。在不断增长的内部 UITableViewCell
的 UITableView
除了一件小事,我几乎就到了。
我有一个 UITableView
有一个自定义 UITableViewCell
.我的UITableView
在 self.tableView.estimatedRowHeight
的帮助下使用新的 iOS8 自适应动态单元格高度和 self.tableView.rowHeight = UITableViewAutomaticDimension;
,它会根据 ContentView 的自动布局增加单元格高度。
我可以适本地种植我的 UITextField
的框架和我的 UITableView
的单元格高度确实增长了,但每次我调用 self.tableView beginUpdates
和匹配的 endUpdates
,我的 tableView 的整个 ScrollView 强制滚动到 TableView 的顶部。我有一个滚动到插入符号位置的方法,但正如您想象的那样,每次在 UITextView 中创建一个新行时,UITableView 都会滚动到最顶部,然后滚动到插入符号位置,这非常糟糕。
有人有什么想法吗?如有必要,我可以提供视频。干杯, 迈克
最佳答案
这也让我很困惑,看起来 self.tableView.estimatedRowHeight
就是问题所在。当我做出足够大的估计时,问题就停止了。
我添加了这个,到目前为止它运行良好:
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
关于ios - UITableView beginUpdate/endUpdate 导致滚动到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29314535/