SoFunction
Updated on 2025-04-07

IOS development UITableView Delete Table Cell Writing

IOS development UITableView Delete Table Cell Writing

Implementation code:

- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
      forRowAtIndexPath:(NSIndexPath *)indexPath {
  if (editingStyle == UITableViewCellEditingStyleDelete) {
    NSDictionary *section = [data objectAtIndex:];
    if (section) {
      NSMutableArray *content = [section valueForKey:@"content"];
      if (content &&  < [content count]) {
        [content removeObjectAtIndex:];
      }
    }
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
  } 
 else if (editingStyle == UITableViewCellEditingStyleInsert) {
    NSDictionary *section = [data objectAtIndex:];
    if (section) {
      // Make a local reference to the editing view controller.
      EditingViewController *controller = ;
      NSMutableArray *content = [section valueForKey:@"content"];
      // A "nil" editingItem indicates the editor should create a new item.
       = nil;
      // The group to which the new item should be added.
       = content;
       = [section valueForKey:@"name"];
       = [section valueForKey:@"types"];
      [ pushViewController:controller animated:YES];
    }
  }
}


That line needs to be added by yourself and then set the property of the newly added line to UITableViewCellEditingStyleInsert

If you have any questions, please leave a message or go to the community of this website to communicate and discuss. The above is an example of how to write UITableView in IOS to delete the form unit. Thank you for reading. I hope it can help you. Thank you for your support for this website!