Getting bad access while deleting cell and reloading table view

后端 未结 1 1817
一个人的身影
一个人的身影 2021-01-20 23:20

I am trying to build a table using custom UITableViewCell, but after deleting cell and when I try load the view, I get an EXC_BAD_ACCESS error,here i\'m getting data from a di

相关标签:
1条回答
  • 2021-01-20 23:59

    Try this: [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

    You must use this method also:

    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
       return UITableViewCellEditingStyleDelete; 
    } 
    
    
    
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
    [contents removeObjectAtIndex:indexPath.row];
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    //[tabelView1 reloadData];
    

    }

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