Home > Coding, iPhone > Limiting UITableview Cell Moves Between Sections

Limiting UITableview Cell Moves Between Sections

CBD4D958-0624-4B0E-9D08-022F7C6C8CDE.jpg

Problem: You want to limit if a tableview cell is ABLE to move to a new section, or is limited to ONLY moving to a new section. For example in mySlate I’m supporting moving bookmarks to a new section/folder. However the bookmarks are laid out in alphabetical order inside a section/folder, so re-ordering them would do no good. Each time you open the bookmarks view they are returned alphabetically from the data store.

Solution:

- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
    if( sourceIndexPath.section != proposedDestinationIndexPath.section )
    {
        return proposedDestinationIndexPath;
    }
    else
    {
        return sourceIndexPath;
    }
//Reverse those to support only moving inside a section
}

Of course supporting movement in the tableview is yours to implement.

Source: stackoverflow

Post to Twitter Tweet This Post

brandon Coding, iPhone

  1. No comments yet.

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.