*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/co
来源:互联网 发布:node.js excel 编辑:程序博客网 时间:2024/06/10 09:07
在刷新tableView时,往往会遇到这样的情况,突然的程序崩溃,让你防不胜防!
我遇到的情况是这样的,首页tableView分为几个区,每个区的行数是固定的,刷新tableView单个区是没问题的,刷新代码如下:
dispatch_async(dispatch_get_main_queue(), ^{ NSIndexSet * indexSet = [[NSIndexSet alloc]initWithIndex:2]; [self.homeTableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; });
如果我两个区一起刷新,就会出现crash。Debug闪退原因如下:
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3599.6.1/UITableView.m:1610
到stackoverflow相关问题询问了下,还是找到了原因:
reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
大致意思是说你刷新tableView的那个区的行数有变动,应该和你刷新之前的行数一样才行。我的项目需求特殊,每个区的行数固定的,但是我之前写的确实返回行数是根据数组变动的,将之改成固定行数后就不会出现crash。
那么问题来了,如果说我的需求就是要变动删除某行再刷新tableView,这时候行数是不能写死的,那要怎么处理呢?
也简单,查看苹果API你会发现两个方法一个是删除行,一个是删除区,如下:
[_tableView beginUpdates]; //删除行[_tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; //删除区deleteSections:[_tableView endUpdates];
阅读全文
1 0
- *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/co
- *** Assertion failure in -[UITableView _endCellAnimationsWithContext:]
- Assertion failure in -[UITableView _endCellAnimationsWithContext:]---错误
- NSFetchedResultsController Assertion failure in -[UITableView _endCellAnimationsWithContext:]
- *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/C
- Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Cache
- Assertion failure in -[UITableView _dequeueReusableViewOfType:withIdentifier:], /BuildRoot/Library/C
- Assertion failure in -[UITableView _dequeueReusableViewOfType:withIdentifier:], /BuildRoot/Library/C
- 删除cell 报错*** Assertion failure in -[UITableView _endCellAnimationsWithContext:]
- *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit
- 删除cell时 报错 Assertion failure in -[UITableView _endCellAnimationsWithContext:]
- <ObjectC>解决 Assertion failure in -[UITableView _endCellAnimationsWithContext:] 问题
- 报错:*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Librar
- 最新CocoaPods下载库报错ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFramewor
- xcode无限闪退ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-1215
- *** Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:], /BuildRoot/Librar
- *** Assertion failure in -[UITableView layoutSublayersOfLayer:]
- Assertion failure in -[UITableView layoutSublayersOfLayer:]
- 安卓系统修改常用命令
- AgentWeb三方android web开源库的理解和认识
- 中文乱码三种解决方式
- 【复习笔记】关于synchronized的使用整理
- 循环与数组
- *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/co
- 3.2.3配置sqlsrv数据库出现'PDO::SQLSRV_ATTR_ENCODING'的问题
- python学习历程_基础知识(2day)
- hive日志的存储位置
- [Python]网络数据采集概述(4)—爬虫仿浏览器访问
- Flask和Celery的使用
- 重写JavaScript的Math.round方法
- 【Eclipse】快捷键
- Java多线程详解