NSFetchedResultsController Assertion failure in -[UITableView _endCellAnimationsWithContext:]

本文探讨了使用Xcode7连接iOS8.4设备时遇到的UITableView报错问题,指出这可能是Xcode7或iOS9的Bug,并提供了解决方案:在移动单元格时检查旧位置与新位置是否相同。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

近期发现xcode7 连接iphone6(ios8.4)和iphone6plus(ios8.4)时会报错

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-3347.44/UITableView.m:1222

xcode6却不会出现此问题,经过追查,发现uitableview在movecell的时候delete和reload的是同一行。

NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to delete and reload the same index path ( {length = 2, path = 0 - 0}) with userInfo (null)


该问题目前判断为xcode7或者ios9的bug,解决方案为在move时先判断index path和newindexpath是否是同一个即可。

 case .Move:
        if let indexPath = indexPath {
            if let newIndexPath = newIndexPath {
                tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
                tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade)
            }
        }


stackoverflow上有很多体温和解决方案,最符合我的就是如下两个讨论

http://stackoverflow.com/questions/31383760/ios-9-attempt-to-delete-and-reload-the-same-index-path

http://stackoverflow.com/questions/31968574/core-data-setting-the-relationship-on-an-entity-causes-error-in-fetch-results-c

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值