编程技术记录

世界你好!

虽然提示是删除一个section,但不一定显式调用了deleteSection接口,还有可能是reloadSection,一个复现的场景就是reload了一个不存在的section。
例如

//以下为示意代码

tableview = [UITableView alloc] initWithFrame:CGRectMake(0,0,100,400) style:UITableViewStylePlain];

//添加一个section
[tableview.dataSource addObject:section];
//此时,只有一个section,我们reload第二个section
[tableview reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
//崩溃

详细堆栈

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3901.4.5/UITableView.m:2040
2020-05-14 15:17:07.597057+0800 AppTest[33419:3092839] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete section 1, but there are only 1 sections before the update'
*** First throw call stack:
(0x187a92a48 0x1877b9fa4 0x187994e88 0x187dca654 0x18bcc5f44 0x18bcdf9d8 0x18bce0044 0x1021422a0 0x1021420bc 0x1019194e0 0x1019193b0 0x10223d8b4 0x1075817fc 0x107582bd8 0x107590c34 0x187a105e4 0x187a0b5d8 0x187a0aadc 0x1919ab328 0x18bb1863c 0x100e9cfcc 0x187894360)

© Beli. All Rights Reserved.