防止iPhone SDK中特定单元格的单元格重新排序

防止iPhone SDK中特定单元格的单元格重新排序,iphone,Iphone,我的UITableView中有两个部分。我希望第二部分可以移动,但第一部分的单元格不能移动。 指定canEditRowAtIndexPath和canMoveRowAtIndexPath没有帮助-第一部分单元格虽然没有显示拖动控件,但如果拖动第二部分的单元格,它们仍然会改变位置。 是否有解决方法?如果用户试图将第二节中的行移到第一节,请尝试实现targetIndexPathFormoveFromRowatinexPath方法,并强制将第二节中的行移回其原始位置: - (NSIndexPath *)

我的UITableView中有两个部分。我希望第二部分可以移动,但第一部分的单元格不能移动。 指定canEditRowAtIndexPath和canMoveRowAtIndexPath没有帮助-第一部分单元格虽然没有显示拖动控件,但如果拖动第二部分的单元格,它们仍然会改变位置。
是否有解决方法?

如果用户试图将第二节中的行移到第一节,请尝试实现targetIndexPathFormoveFromRowatinexPath方法,并强制将第二节中的行移回其原始位置:

- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
    if (proposedDestinationIndexPath.section == 0)
    {
        return sourceIndexPath;
    }
    else 
    {
        return proposedDestinationIndexPath;
    }
}