Just need 3 delegate methods:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSUInteger count = [savedTask count];
if (row < count) {
return UITableViewCellEditingStyleDelete;
} else {
return UITableViewCellEditingStyleNone;
}
}
/*
*Commit delete action
*/
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSUInteger count = [savedTask count];
if (row < count) {
NSMutableArray* temparr = [[NSMutableArray alloc] initWithArray:savedTask];
[temparr removeObjectAtIndex:row];
savedTask = temparr;
}
}
- (void)tableView:(UITableView *)tableView
didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView reloadData];
}
Không có nhận xét nào:
Đăng nhận xét