ios cell 重用问题--图片remove
2015-07-29 09:07
411 查看
因为一个UITableView 会reload 多次,所以在cell中添加 UI控件时,也会重复加载多次,以至于叠加在上面, 解决办法: 每次用到它时,对其进行初始化做判断,为空则初始化,否则 就不init UIImageView *_rightImageView = (UIImageView*)[cell viewWithTag:1007]; if ((UIImageView*)[cell viewWithTag:1007] == nil) { _rightImageView = [[UIImageView alloc]initWithFrame:CGRectMake(DEVICEWIDTH - 55, 8, cellImageWidth, cellIimagehight)]; _rightImageView.tag = 1007; } if (_License ) { if (_rightImageView != nil) { [(UIImageView*)[cell viewWithTag:1007] removeFromSuperview]; } // UILabel *_tempLabel = [self generateNameLabel:_status]; _tempLabel.text = _status; [cell addSubview:_tempLabel]; }
相关文章推荐
- ios 异常捕获
- ios 编码规范
- iOS上架
- 为学IOS,进击中......
- iOS 设计模式之中介者模式
- iOS-代理委托的使用
- iOS开发小案例之根据年份判断生肖
- iOS自动布局高级用法及纯手码约束写法
- [精通iOS开发(第5版)]第17章 轻击、触摸和手势 笔记
- ios状态栏操作
- iOS开发之软键盘使用小技巧
- 9秒学院教你如何成为iOS开发达人
- iOS 开发一些小技巧(收集整理)
- iOS开发:iOS中几种数据持久化方案:你要永远地记住!
- xcode 6.4 下 IOS 8.4 隐藏模拟器的状态栏
- IOS动画之抖动
- iOS开发——OC基础-ARC、BLOCK、协议
- iOS学习之MVC设计模式的理解
- iOS的文件管理——沙盒(sandbox)
- IOS switch-case知多少