Skip to content

Instantly share code, notes, and snippets.

@simonnickel
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save simonnickel/9048440 to your computer and use it in GitHub Desktop.

Select an option

Save simonnickel/9048440 to your computer and use it in GitHub Desktop.

Revisions

  1. simonnickel renamed this gist Jun 6, 2014. 1 changed file with 13 additions and 6 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,22 @@
    #pragma mark - SNLInteractionTableView delegate - Reorder

    - (void)startedReorderAtIndexPath:(NSIndexPath *)indexPath {
    // additional setup when reordering starts
    NSLog(@"Reordering started");
    }

    // Update your data source when a cell is draged to a new position. This method is called every time 2 cells switch positions.
    - (void)moveRowFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
    // update DataSource when cells are switched
    NSLog(@"Switched Cells");

    // Reorder example:
    id object = [self.itemList objectAtIndex:fromIndexPath.row];
    [self.itemList removeObjectAtIndex:fromIndexPath.row];
    [self.itemList insertObject:object atIndex:toIndexPath.row];
    }

    /* if needed
    - (void)startedReorderAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"Reordering started");
    }
    - (void)finishedReorderAtIndexPath:(NSIndexPath *)indexPath; {
    // additional cleanup when reordering ended
    NSLog(@"Reordering ended");
    }
    */
    }
  2. simonnickel revised this gist Feb 17, 2014. 1 changed file with 3 additions and 8 deletions.
    11 changes: 3 additions & 8 deletions SNInteraction configure reordering
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,15 @@
    // Update your data source when a cell is draged to a new position. This method is called every time 2 cells switch positions.
    - (void)moveRowFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
    /*
    * Reorder example:
    */
    // Reorder example:
    id object = [self.itemList objectAtIndex:fromIndexPath.row];
    [self.itemList removeObjectAtIndex:fromIndexPath.row];
    [self.itemList insertObject:object atIndex:toIndexPath.row];
    }

    /* Uncomment this function if you need additional setup when reordering starts.
    /* if needed
    - (void)startedReorderAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"Reordering started");
    }
    */
    /* Uncomment this function if you need additional cleanup when reordering ended.
    - (void)finishedReorderAtIndexPath:(NSIndexPath *)indexPath; {
    - (void)finishedReorderAtIndexPath:(NSIndexPath *)indexPath; {
    NSLog(@"Reordering ended");
    }
    */
  3. simonnickel created this gist Feb 17, 2014.
    20 changes: 20 additions & 0 deletions SNInteraction configure reordering
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // Update your data source when a cell is draged to a new position. This method is called every time 2 cells switch positions.
    - (void)moveRowFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
    /*
    * Reorder example:
    */
    id object = [self.itemList objectAtIndex:fromIndexPath.row];
    [self.itemList removeObjectAtIndex:fromIndexPath.row];
    [self.itemList insertObject:object atIndex:toIndexPath.row];
    }

    /* Uncomment this function if you need additional setup when reordering starts.
    - (void)startedReorderAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"Reordering started");
    }
    */
    /* Uncomment this function if you need additional cleanup when reordering ended.
    - (void)finishedReorderAtIndexPath:(NSIndexPath *)indexPath; {
    NSLog(@"Reordering ended");
    }
    */