tableView
행을 삭제하고 싶습니다. 데이터베이스에서 행을 삭제할 수 있지만 내 tableview의 행은 사라지지 않습니다. 감사합니다. !!! 는 MaytecommitEditingStyle : 데이터를 삭제하지만 행을 계속 표시합니다.
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
PFUser *user = [self.allProducts objectAtIndex:indexPath.row];
[_mipedido removeObject:[PFObject objectWithoutDataWithClassName:@"almacen"objectId:user.objectId]];
[[PFUser currentUser] saveInBackground];
NSMutableArray *pedido = [[NSMutableArray alloc] init];
for (int i = 0; i <= 1; i++)
{
[pedido removeObject:[NSIndexPath indexPathForItem:i inSection:1]];
}
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:pedido withRowAnimation:NO];
[tableView endUpdates];
}
[tableView reloadData];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier [email protected]"editSnacksTableViewCell";
editSnacksTableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
NSArray *nib =[[NSBundle mainBundle] loadNibNamed:@"editSnacks" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
PFUser *user = [self.allProducts objectAtIndex:indexPath.row];
cell.precio.text = [NSString stringWithFormat:@"%f",[[precioProducto text] doubleValue]];
cell.nombreProducto.text =user[@"nombreProducto"];
// cell.photoSnacks.image = [UIImage imageNamed:[thumbnails objectAtIndex:indexPath.row]];
// cell.descripcionSnakcs.text =[tableData objectAtIndex:indexPath.row];
return cell;
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
self.mipedido = [[PFUser currentUser] objectForKey:@"mipedido"];
PFQuery *query = [self.mipedido query];
// [query whereKey:@"nombreProducto" notEqualTo:self.currentUser.username];
[query orderByAscending:@"nombreProducto"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error %@ %@", error, [error userInfo]);
}
else {
self.allProducts =objects;
[self.tableView reloadData];
}
}];
}
로 : 당신이 읽을 데이터베이스가 _mipedido 경우
전반적으로, 코드, 다음과 같아야 다음 indexPath에게 사용자를 삭제하기 위해
사용, 슬쩍 당신은 백그라운드에서 저장하고 있습니다, 그것은 당신이 데이터베이스를 다시 읽기 전에 저장할 시간이 없었을 수 있습니다. 동 기적으로 저장해보십시오. –
지 점, 내 문제에 관심을 가져 주셔서 대단히 감사합니다. 사실, 나는 내 코드를 변경하기 위해 도달하고 마침내 나는 어떤 충돌도하지 않지만 나는 내가 최근에 삭제 한 행을 계속해서 보게된다. 상쾌하게하는 것 같아요. vviewWillAppear에서 Parse를 사용합니다. 이게이 문제의 원인인지 나는 모른다. 미리 감사드립니다. –
인덱스 경로 객체가 'pedido'에 추가 된 위치는 어디입니까? –