TableViewCell 复用解决
2016-06-14 14:02
190 查看
在Storyboard中 的tableViewCell每个cell包含了一个播放器。有时会出现复用的情况。针对此种情况做以下修改——————- 将cell写入Xib,解决了重复显示的问题。
参考的博文内容来自
http://www.itnose.net/detail/6154013.html
- (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
相关文章推荐
- asp.net Framework 与 asp.net core 知识
- C++ eof()函数相关应用技巧分享
- getCacheDir()、getFilesDir()、getExternalFilesDir()
- [读书笔记]《Java程序员修炼之道》
- Ubuntu服务器之间进行Sersync+Rsync同步
- 大数据Kafka
- IIS 7 支持10万并发请求
- Java Thread
- PHP代码审计】 那些年我们一起挖掘SQL注入 - 1.什么都没过滤的入门情况
- 在raspberry运行xibo
- 解决升级Xcode后VVDocumenter无效
- 下载文件打包 zip java
- 来自全球的14个编码社区
- 使用migrate.exe执行EF code first 迁移
- JSON
- Android 判断View是否被遮挡
- 【iOS开发】Foreign famous blogs
- jquery获得复选框checkbox中选中的值
- Android--Demo_PullToRefresh(基础篇)
- 从零构建OpenStack(1) 云计算相关概念及OpenStack介绍