TableViewCell重用报错

2019-04-08  本文已影响0人  white_W

2019-04-08 10:24:26.730650+0800 NucleusGene[72621:1459162] *** Assertion failure in -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.54.4/UITableView.m:7882

(lldb)

网上的资料说的是用不用ForIndexPath的区别,或者是签名没有注册Cell的失误。

仔细查看了一下,我在同一个层级下写了两个

[tableView dequeueReusableCellWithIdentifier:@"cell1" forIndexPath:indexPath];

[tableView dequeueReusableCellWithIdentifier:@"cell2" forIndexPath:indexPath];

相当于我对同一个indexPath 引用了两个 Identifier ,分别为@“cell1”,@“cell2”,从而导致的崩溃。

资料说用不用 forIndexPath 的区别应该就是因为给当前的indexPath分配了两个Identifier,而导致的冲突,如果我们不用indexPath,那Identifier就不会与 indexPath 绑定 ,而不会冲突。

上一篇 下一篇

猜你喜欢

热点阅读