Guest User

Untitled

a guest
May 23rd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  2. [tableView beginUpdates];
  3. if (editingStyle == UITableViewCellEditingStyleDelete) {
  4. // Do whatever data deletion you need to do...
  5. // Delete the row from the data source
  6. [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:YES];
  7. }
  8. [tableView endUpdates];
  9. }
  10.  
  11. // If I want to delete the next 3 cells after the one you click
  12. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  13. {
  14. NSMutableArray* indexPaths = [NSMutableArray array];
  15. for (int i = indexPath.row + 3; i < indexPath.row + 3; i++)
  16. {
  17. [indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
  18. }
  19.  
  20. [tableView beginUpdates];
  21. [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
  22. [tableView endUpdates];
  23. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  24. }
Add Comment
Please, Sign In to add comment