tags:

views:

28

answers:

1

Hello!

I have 2 sections in my UITableView. I want the 2nd section to be movable but the 1st section of cells not. Specifying canEditRowAtIndexPath and canMoveRowAtIndexPath doesn't help - the first section cells although not showing drag controls, they still change places if a cell from the 2nd section is dragged over. Is there a workaround for this?

+2  A: 

Try implementing the targetIndexPathForMoveFromRowAtIndexPath method and forcing the row from the second section back to its original place if user tries to move it to the first section:

- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
    if (proposedDestinationIndexPath.section == 0)
    {
        return sourceIndexPath;
    }
    else 
    {
        return proposedDestinationIndexPath;
    }
}
DyingCactus
Awesome, thanks! Can't believe i missed this method ;]
hveveris