UITableViewCell的刪除,只需要實(shí)現(xiàn)以下4個(gè)方法:
pragma mark - 左滑刪除
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
return YES;
}
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return UITableViewCellEditingStyleDelete;
}
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
return @"刪除";
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
if(editingStyle == UITableViewCellEditingStyleDelete){
[_timeArray removeObjectAtIndex:indexPath.section];
NSIndexSet *sectionIndex = [NSIndexSet indexSetWithIndex:indexPath.section];
[tableView deleteSections:sectionIndex withRowAnimation:UITableViewRowAnimationAutomatic];
}
}


