Ján*_*nos 8 reorderlist uitableview ios heightforrowatindexpath
我让用户重新排序行tableView.因为此事件影响内容 - 单元格中的某些数值应该更新 - 在所有其他行中,我调用reloadDatain moveRowAtIndexPath.然后发生奇怪的效果.
即触摸拖动器时,细胞似乎重叠,并且一些细胞开始上下移动.重要的是要知道,细胞高度是变化的.
奇怪的是,如果我reloadData从中删除moveRowAtIndexPath,那么所有这些现象都会消失.只有内容无效.
那么重新排序后如何重新加载数据呢?
更新:我做了什么同时重新配置单元格viewDidLayoutSubviews而不是呼叫reloadData结束moveRowAtIndexPath.它的工作效果比我预期的要高90%,但有时它们的行数仍然有些高.
override func tableView(tableView: UITableView, moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) {
//..
reorderOccured = true
}
override func viewDidLayoutSubviews() {
if reorderOccured {
for cell in tableView.visibleCells() as! [UITableViewCell] {
let ip = tableView.indexPathForCell(cell)
if ip != nil {
self.configureCell(cell, indexPath: ip!)
}
}
reorderOccured = false
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里找到了答案:/sf/answers/328479441/
[tableView beginUpdates];
[tableView endUpdates];
Run Code Online (Sandbox Code Playgroud)
此代码强制 UITableView 仅重新加载单元格大小,但不重新加载单元格内容。
| 归档时间: |
|
| 查看次数: |
1875 次 |
| 最近记录: |