Tag: 删除行

commitEditingStyle:删除数据,但继续显示行

我想删除我的tableView的行。 我可以从数据库中删除行,但我的tableview中的行不会消失。 非常感谢!!! Mayte -(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]]; } […]

使用核心数据删除包含animation的表格行

如果我使用标准animation(如UITableViewRowAnimationFade从表中删除一行,则代码将崩溃,并显示以下错误: ***终止应用程序,由于未捕获exception“NSInternalInconsistencyException”,原因:“无效更新:在第1部分中的行数无效。更新(4)后,现有节中包含的行数必须等于行数在更新之前包含在该部分(4)中,加上或减去从该部分插入或删除的行数(0插入,1删除)。 如果我删除animation行的行删除/删除作品,但我不再有酷苹果删除过渡。 这是我的代码 – 任何帮助表示赞赏。 这种删除行的方法在iOS4之前工作,不知道是否有什么改变? – (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // If row is deleted, remove it from the list. if (editingStyle == UITableViewCellEditingStyleDelete) { NSIndexPath *path = [NSIndexPath indexPathForRow:indexPath.row inSection:0]; MyItem *myItem = [self.getItemsFetchedResultsController objectAtIndexPath:path]; [dataRepository deleteItem:myItem]; // If I comment this line out the delete works but I no […]

在从UITableView中删除项目之后,索引超出范围

请帮我看看我的错误是什么 我有一个表视图,数据源是一个名为items的数组。 从items数组中删除一个项目后,调用cellForRowAt方法,参数indexPath.row与items.count相等。 这只会发生,当行数足够一个项目不在表视图的视图。 发生时会导致严重的错误(索引超出范围)。 在这种情况下使用黑客攻击,并且IndexPath.row的值会减less。 请看下面的图片: 以下代码为cellForRowAt: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "ItemCell", for: indexPath) as! ItemCell var i = indexPath.row if i >= items.count { i = items.count – 1 } //XXX: hack! Sometimes called with indexPath.row is equal with items.count 🙁 cell.set(items[i]) return […]

UIButton&UITextField将阻止UITableViewCell被刷卡删除

UITableViewCell有UIButton和UITextField 。 删除button 当我滑过UIButton或UITextField时不会出现。 我search的SO和谷歌的答案,有一个类似的问题滑动左手势UITextField ,但没有正确的答案。 我在iOS 8上遇到了这个问题。 编辑后设置self.tableView.panGestureRecognizer.delaysTouchesBegan = YES; ,它适用于具有UITextField单元格。 但是,当我从UIButton拖动开始,删除button显示和UIButton解雇,我不希望UIButton被解雇。