UITableView的cellForRow代理完全正确,但是滑动很快的时候,其中一个Label就会有重影,而且是重用那几个重影。代理的方法如下:
static NSString *CellIdentifier = @"Cell";
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
......
return cell;但是就是有重影,找了好久网上的原因,说把
[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 改为[tableView <span style="color: rgb(63, 63, 63); font-size: 14px; line-height: 30px;">cellForRowAtIndexPath:indexPath</span>]; 但是这样就失去了重用机制的初衷。
最后还是没有在网上找到原因,就开始看storyBoard中找原因,终于找到了
如图,选项clears Graphics Context如果不勾选,重新赋值的时候,就不会清除图形上下文,导致重影的不是cell的重用,而是上下文对问题而已。
本文探讨了UITableView中cellForRow代理方法实现下,滑动快速时出现Label重影现象的原因,并通过设置Storyboard中的clearsGraphicsContext选项解决该问题。
1279

被折叠的 条评论
为什么被折叠?



