您的位置:首页 > 其它

自定义cell中使用添加多个图片并自适应cell高度(类型于电商平台的商品评价添加图片)

2016-07-04 16:45 423 查看
Demo实例

使用注意事项:

1、根据图片个数,及最大数限制换行和高度计算;

// 计算实际视图高度
+ (CGFloat)getImageAddMoreViewRealHeight:(NSInteger)count maxCount:(NSInteger)countMax
{
CGFloat height = originY + originY;

// 非最后一个时,添加一个添加图片的按钮
NSInteger countButton = (count < countMax ? 1 : 0);
NSInteger countReal = count + countButton;
NSInteger row = countReal / imageRowCount;
row += ((countReal % imageRowCount == 0) ? 0 : 1);

height += (row * sizeImage + (row - 1) * originY);

return height;
}
2、图片数据改变后,刷新tableview

// 刷新数据
// 方法1
[weakSelf.mainTableView reloadData];
// 方法2
[weakSelf.mainTableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
// 方法3
[weakSelf.mainTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];

效果图


  



  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: