At canEditRowAtIndexPath Method, reloadData of UITableView not work properly?

前端 未结 5 782
离开以前
离开以前 2021-01-05 23:05

In my application, I reload my TableView ([tablView reloadData];) after delete row from TableView then canEditRowAtIndexPath Method alway

5条回答
  •  攒了一身酷
    2021-01-05 23:11

    the 'removeObjectAtIndex:indexPath' takes some time and I suspect your [self.tblView reloadData] is being called early. I tried a sample code and found success with [UiTableView beginUpdates] and [UiTableView endUpdates] you may also avoid crash if you put a little delay before the reloading or deleting rows haven't tried it though

    [tableTable beginUpdates];
    [tableArray removeObjectAtIndex:indexPath.row];
    [tableTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    [tableTable endUpdates];
    

提交回复
热议问题