- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
if(editingStyle == UITableViewCellEditingStyleDelete){
//[theSimpsons removeObjectAtIndex:indexPath.row];
NSString *time = [[arrayList objectAtIndex:indexPath.row] objectForKey:@"TIME"];
NSString *date= [[arrayList objectAtIndex:indexPath.row] objectForKey:@"DATE"];
DBManager *dbm = [[DBManager alloc] init];
[dbm initiallzeDatabase];
[dbm deleteItemAtIndexPath:time :date];
//arrayList = [dbm getParkResults];
//[parkTableView reloadData];
[arrayList removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
这是我应用中的部分代码,编辑部分很正常,只是删除键只有在单元中从左至右滑动时才显示。现在我有一个从左至右打开的菜单,我想让用户从右至左滑动时,删除键也会显示。