不要让单元格移动到另一个部分

use*_*246 8 iphone uitableview

如何禁用用户可以将单元格移动到其他部分?我不想每次都显示警报;)

感谢:D

小智 13

实现targetIndexPathForMoveFromRowAtIndexPath委托方法:

- (NSIndexPath *)tableView:(UITableView *)tableView 
    targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath 
    toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
    if (proposedDestinationIndexPath.section != sourceIndexPath.section)
    {
        //keep cell where it was...
        return sourceIndexPath;
    }

    //ok to move cell to proposed path...
    return proposedDestinationIndexPath;
}
Run Code Online (Sandbox Code Playgroud)