delete in tableView

后端 未结 1 373
情深已故
情深已故 2021-01-29 09:44

I just add this methods in .h file :

- (IBAction)EditTable:(id)sender;

- (IBAction)DeleteButtonAction:(id)sender;

and in .m file :

1条回答
  •  悲&欢浪女
    2021-01-29 10:19

    If I am not wrong then you want to delete the cell of the tableView when delete button is clicked....

    You need to call one other method of tableview:

    //To Delete the Data
    - (void)setEditing:(BOOL)editing animated:(BOOL)animated {
        // Updates the appearance of the Edit|Done button as necessary.
        [super setEditing:editing animated:animated];
        [tblViewBM setEditing:editing animated:YES];
        // Disable the add button while editing.
    }
    
    
    - (void)tableView:(UITableView *)tableView commitEditingStyle:
    (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
     if (editingStyle == UITableViewCellEditingStyleDelete) {
    
    //Use your Array from which you need to delete the data.
      NSMutableDictionary *dict=(NSMutableDictionary *)[appDel.BookMarkAry objectAtIndex:indexPath.row];
      type=[dict valueForKey:@"type"];
    
      [appDel.BookMarkAry removeObjectAtIndex:indexPath.row];
    
    
      [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    
    
      [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
     } 
    }
    

    I am sure this will Definately help you to delete the cell with data from array also.

    0 讨论(0)
提交回复
热议问题