iOS 开发 iOS Developer

TableViewCell的复用

2016-09-20  本文已影响101人  海泉

:滑动tableView,cell会添加到复用的cell上

就像这样子 报错是这样子的

初步判断,是cell的复用有问题,看了看,有这么个方法

- (void)prepareForReuse;                                                        // if the cell is reusable (has a reuse identifier), this is called just before the cell is returned from the table view method dequeueReusableCellWithIdentifier:.  If you override, you MUST call super.

在方法中把子视图移除,这方法不好。因为在view中创建了cell,其就不能是空

这是现在的

填坑方法:就是cell的复用问题,在复用的cell重复创建cell再赋值,取得复用cell后判断一下就好了。

上一篇下一篇

猜你喜欢

热点阅读