【发布时间】:2025-12-23 23:05:06
【问题描述】:
我正在创建一个列表应用程序,用户可以在其中检查项目,在短暂延迟后检查时,选中的项目会移动到底部(UITableView 中的不同部分)。用户可以通过点击它来“取消选中”该项目,然后它会移回原始部分。
我的问题是,当单元格在这样的部分之间移动时,UITableView 似乎对哪些单元格在哪里感到“困惑”。
当我 NSLog 我正在与之交互的单元格的 IndexPath.row 时,它返回的行与我正在触摸的行不同。我使用[self.tableView moveRowAtIndexPath:from_indexPath toIndexPath:to_indexPath]; 在部分之间移动单元格。这是我的一些代码:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
switch (indexPath.section) {
case SECTION_ACTIVE:{
ItemData *dataForCell = [activeList objectAtIndex:indexPath.row];
NSLog(@"%@ \t %d",dataForCell.title, indexPath.row);
if (dataForCell.isHeader) {
NSLog(@"%d",indexPath.row);
return 70;
}
break;
}
default:
break;
}
return 55;
}
有没有办法解决这个问题?或者解决这个问题?
【问题讨论】:
标签: ios uitableview