TableViewCell 复用解决
来源:互联网 发布:重庆行知教育集团 编辑:程序博客网 时间:2024/04/30 11:31
在Storyboard中 的tableViewCell每个cell包含了一个播放器。有时会出现复用的情况。针对此种情况做以下修改——————- 将cell写入Xib,解决了重复显示的问题。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ // 定义唯一标识 NSString *CellIdentifier = [NSString stringWithFormat:@"AudioListCell%ld%ld",indexPath.section,indexPath.row]; // 通过indexPath创建cell实例 每一个cell都是单独的 AudioListCell *cell = [tableView cellForRowAtIndexPath:indexPath]; // 判断为空进行初始化 --(当拉动页面显示超过主页面内容的时候就会重用之前的cell,而不会再次初始化) if (!cell) { UINib* nib = [UINib nibWithNibName:@"AudioListCell" bundle:[NSBundle mainBundle]]; [tableView registerNib:nib forCellReuseIdentifier:CellIdentifier]; cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; } AudioFileInfoModel *fileInfo = self.dataArray[self.dataArray.count-indexPath.row-1]; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!cell.isInit) { [cell setValueWithfileInfo:fileInfo]; cell.isInit = YES; } __weak __typeof(&*self)weakSelf = self; cell.delegate = weakSelf; cell.reuploderBlock = ^(BOOL reuploderOrNot){ if (reuploderOrNot) { [weakSelf.auidoCachesManager re_uploadFile:fileInfo andInteger:weakSelf.dataArray.count-indexPath.row-1]; } }; return cell;}
参考的博文内容来自
http://www.itnose.net/detail/6154013.html
0 0
- TableViewCell 复用解决
- 解决tableviewCell覆盖的问题以及tableviewCell复用原理
- 解决tableViewCell的复用问题的方法
- tableViewCell的复用方法
- TableViewCell注册及复用
- iOS tableViewCell复用问题
- Storyboard 下 TableViewCell的复用
- 自定义tableViewCell 的复用问题
- TableViewCell内含textField的复用
- tableviewcell
- tableViewcell
- tableViewCell
- tableViewCell
- TableViewCell
- UITableView使用及TableViewCell的复用机制
- TableViewCell的复用出现数据重复的解决方法
- 用willDisplayCell改变TableViewCell颜色
- IOS storyboard解决TableViewCell底线无法到头问题
- 大数据Kafka
- C++ eof()函数相关应用技巧分享
- getCacheDir()、getFilesDir()、getExternalFilesDir()
- [读书笔记]《Java程序员修炼之道》
- SpringMVC 基于注解的Controller详解
- TableViewCell 复用解决
- Android学习笔记--GMS认证(常见的cts—fail及解决方法)
- iOS Autolayout之Masonry解读
- Unreal Engine4(虚幻4)学习心得-Ambient Cubemap 环境立方体贴图
- QTP录制
- eclipse 闪退
- 第十六周实践项目3————电子词典
- 章文嵩博士和他背后的负载均衡帝国
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解(转载)