How to create a toolbar between UITableView rows

前端 未结 6 1716
终归单人心
终归单人心 2020-12-12 09:05

I am interested on how tweetbot does the following:

\"Enter

I would like to cr

6条回答
  •  旧巷少年郎
    2020-12-12 10:05

    @rjgonzo this works great but there is a minor issue on how you keep the indexPathToDelete. Since it's just another pointer to self.controlRowIndexPath, once you clear or reassign the self.controlRowIndexPath, indexPathToDelete will not be what you wanted, and tableView deleteRowsAtIndexPaths:withRowAnimation: call, you will get an SIGBART crash.

    so, instead of

        //pointer to delete the control cell
        NSIndexPath *indexPathToDelete = self.controlRowIndexPath;
    

    and

        //lets delete the control cell, either the user tapped the same row twice or tapped another row
        if(indexPathToDelete){
            [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPathToDelete] 
                          withRowAnimation:UITableViewRowAnimationNone];
        }
    

    the following code should work fine:

        //pointer to delete the control cell
    NSIndexPath *indexPathToDelete = [NSIndexPath indexPathForRow:self.control_row_index_path.row inSection:self.control_row_index_path.section];
        ...
        ...
        //lets delete the control cell, either the user tapped the same row twice or tapped another row
    if(indexPathToDelete.row != 0){
        NSLog(@"row to delete %d", indexPathToDelete.row);
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPathToDelete] withRowAnimation:UITableViewRowAnimationNone];
    }
    

提交回复
热议问题