iOS--当cell上显示不同数量图片的时候重用
2016-01-25 15:05
375 查看
原文链接:https://www.geek-share.com/detail/2664705500.html
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //标识符 static NSString *iden = @"cardsCell"; CardsCell *cell = [tableView dequeueReusableCellWithIdentifier:iden]; Cards *cards = [self.cardsArr objectAtIndex:indexPath.row]; //cell为空就创建 if (cell == nil) { cell = [[CardsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:iden]; }else { //如果存在cell需要把之前添加的会变化的控件删除 //删除cell上添加的图片 [cell.photoGroup removeFromSuperview]; } cell.cards = cards;; return cell; }
在自定义cell里
- (void)setCards:(Cards *)cards { if (_cards != cards) { _cards = cards; } //给cell控件赋值 [self.avaImageView sd_setImageWithURL:[NSURL URLWithString:_cards.avaImageUrl] placeholderImage:[UIImage imageNamed:@"72tx.png"]]; self.usernameLabel.text = _cards.username; self.commentLabel.text = [NSString stringWithFormat:@"%ld",_cards.replyArr.count]; self.titleLabel.text = _cards.title; self.timeLabel.text = _cards.time; self.contextLabel.text = _cards.context; //判断图片数组数量,大于0就根据数量创建,否则不创建 if (_cards.imageArr.count > 0) { //图片浏览,用了一个图片浏览器SDPhotoGroup,继承UIView self.photoGroup = [[SDPhotoGroup alloc] initWithFrame:CGRectMake1(0, 100, 105*_cards.imageArr.count, 60)]; NSMutableArray *temp = [NSMutableArray array]; [_cards.imageArr enumerateObjectsUsingBlock:^(NSString *src, NSUInteger idx, BOOL *stop) { SDPhotoItem *item = [[SDPhotoItem alloc] init]; item.thumbnail_pic = src; [temp addObject:item]; }]; self.photoGroup.photoItemArray = [temp copy]; [self.contentView addSubview:self.photoGroup]; } }
转载于:https://www.cnblogs.com/zhangshan/p/5157494.html
相关文章推荐
- iOS--当cell上显示不同数量图片的时候重用
- IOS学习 NSOperation 网络下载图片 涉及plist文件、重用Cell、占位图、缓存池、清理内存
- IOS UINavigationController UITabBarController嵌套使用的时候显示消息数量
- [VB.NET]怎样在DataGrid控件中显示不同数量的不同图片呢?
- iOS中cell中多个图片显示方案实现
- 如何利用TTThumbsViewController实现显示不同数量的图片?
- iOS UITableViewCell使用gif图片的卡顿和重用问题
- ios 自定义cell右侧的图片显示
- 猫猫学iOS 之微博项目实战(10)微博cell中图片的显示以及各种填充模式简介
- iOS UITableViewCell重用机制避免重复显示问题
- iOS 使用SDwebImage缓存图片并在断网时候显示
- iOS不得姐项目--精华模块上拉下拉的注意事项,日期显示,重构子控制器,计算cell的高度(只计算一次),图片帖子的显示
- iOS cell中添加按钮图片,图片不显示,点击有反应
- UI10_cell自适应高度(显示尺寸不同图片.长短不一的字符串)
- 如何使用GridView实现不同数量显示图片不同的大小
- IOS中启动APP的时候,启动图片全屏,app完成启动之后显示状态栏
- iOS cell重用机制导致数据重叠显示解决方法
- ios cell 重用问题--图片remove
- AJ学IOS 之微博项目实战(10)微博cell中图片的显示以及各种填充模式简介
- iOS中根据网络环境显示不同图片