前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >tabviewcell侧滑删除出现的异常

tabviewcell侧滑删除出现的异常

作者头像
rectinajh
发布2018-05-17 16:10:17
9970
发布2018-05-17 16:10:17
举报

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 1. The number of rows contained in an existing section after the update (22) must be equal to the number of rows contained in that section before the update (22), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

由于未捕获异常“NSInternalInconsistencyException”而终止应用程序, 原因:“无效更新:section 1中的行数不正确。更新后现有段中包含的行数(22)必须等于该行中包含的更新前的行数 (22),加或减该部分插入或删除的行数(0插入,1删除)和加或减,移入或移出该部分的行数(0移入,0移出)。

解决方案:因为数据是从coredata取出的,删除单元格因该先将数据从coredata删除。

if (editingStyle == UITableViewCellEditingStyleDelete) { if (indexPath.row < [self.cloudFileArray count]) { [tableView beginUpdates]; id object = [self.cloudFileFetchController objectAtIndexPath:indexPath]; AppDelegate *appDelegate = [UIApplication sharedApplication].delegate; NSManagedObjectContext *ctx = [appDelegate.localManager managedObjectContext]; [ctx deleteObject:object]; [tableView reloadData]; [tableView endUpdates]; } }

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016.12.07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档