0

有没有人遇到过这种情况?

当我从最底部到最顶部重新排序单元格时,我会崩溃。这些崩溃发生在 iSourceIndexPath.row 变为 0 时。我想知道我的 iSourceIndexPath.row 是如何变为 0 的,因为这是我总是选择的最后一行。有什么线索吗?

- (NSIndexPath *)tableView:(UITableView *)iTableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)iSourceIndexPath toProposedIndexPath:(NSIndexPath *)iProposedDestinationIndexPath {
    NSIndexPath *aReturnIndexPath = iProposedDestinationIndexPath;
    if(iProposedDestinationIndexPath.row == 0) {
        aReturnIndexPath = iSourceIndexPath;
    }

    NSLog(@"iProposedDestinationIndexPath=%d iSourceIndexPath=%d aReturnIndexPath=%d",iProposedDestinationIndexPath.row,iSourceIndexPath.row,aReturnIndexPath.row);
    return aReturnIndexPath;
}
4

1 回答 1

0

移动单元格后我忘记重新加载表格。除了定期处理其中的单元格之外,您还应该这样做。

- (void)tableView:(UITableView *)iTableView moveRowAtIndexPath:(NSIndexPath *)iFromIndexPath toIndexPath:(NSIndexPath *)iToIndexPath {
    [self.tableView reloadData]
}
于 2012-05-10T01:37:31.730 回答