您的位置:首页 > 产品设计 > UI/UE

UITableView中的cell重用正确,但是重影

2015-09-22 15:30 417 查看
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的重用,而是上下文对问题而已。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: