ios学习笔记UITableViewCell重用时出现重影的解决方案
2015-12-29 15:12
501 查看
在UITableView中进行cell 的重用时,偶尔会出现重影的现象通常我们这样写:- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *stee = @"hello";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:stee];if (cell == nil){cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:stee];cell.accessoryType = UITableViewCellAccessoryNone;}//标题TitleL=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 60, cell.contentView.frame.size.height)];[cell.contentView addSubview:TitleL];TitleL.text=@"xxx";}出现重影之后我们可以这样写:- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *stee = @"hello";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:stee];if (cell == nil){cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:stee];cell.accessoryType = UITableViewCellAccessoryNone;//标题TitleL=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 60, cell.contentView.frame.size.height)];TitleL.tag=101;[cell.contentView addSubview:TitleL];}
UILabel *titleL=(UILabel *)[cell.contentView viewWithTag:101];
titleL.text=@"xxxx";
<span style="font-family: Arial, Helvetica, sans-serif;">}</span>
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- Patrol 7 架构下?的处理方法
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 中病毒后常用的解决方法病毒终极解决方案
- 部分喷墨机初始化方法
- QQ尾巴 InfoMs.Ime 解决方案
- C#中数组初始化与数组元素复制的方法
- IE对CSS样式表的限制分析与解决方案
- C#中结构(struct)的部分初始化和完全初始化实例分析
- 开源MySQL高效数据仓库解决方案:Infobright详细介绍
- c#对象初始化顺序实例分析
- 在windows下手动初始化PostgreSQL数据库教程
- 惊现支撑1亿pv/天的超级数据库解决方案
- 关于bluehost空间上wordpress后台变为英文的解决方案
- select * from sp_who的解决方案