- (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];
}
}
我在我的应用程序中使用了上面的代码。编辑部分工作正常,但问题是,只有当我们在单元格上从左向右滑动时才会出现删除按钮。现在我有一个菜单,可以像 Facebook 一样从左到右滑动打开。那么我如何确保当用户从右向左滑动时出现删除按钮。