iOS多种cell使用FDTemplateLayoutCell自动计算高度
来源:互联网 发布:时间都去哪儿了 知乎 编辑:程序博客网 时间:2024/05/22 14:07
两种cell,一种XIBcell,一种代码创建使用masonry布局的cell
项目git地址
注册cell
[_myTable registerNib:[UINib nibWithNibName:@"myIBCell" bundle:nil] forCellReuseIdentifier:@"ibcell"];
[_myTable registerClass:[masonryCell class] forCellReuseIdentifier:@"mcell"];
cell高度计算
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row<3) { return [tableView fd_heightForCellWithIdentifier:@"ibcell" configuration:^(id cell) { [self configCell:cell atindex:indexPath]; }]; }else{ return [tableView fd_heightForCellWithIdentifier:@"mcell" configuration:^(id cell) { [self configCell:cell atindex:indexPath]; }]; } }
xib创建的cell就不多说了,下面贴上代码创建使用masonry布局的cell
//// masonryCell.m// autoheightCell//// Created by jiang on 2017/4/21.// Copyright © 2017年 jiang. All rights reserved.//#import "masonryCell.h"#import "Masonry.h"#import "UIImageView+WebCache.h"@implementation masonryCell- (void)awakeFromNib { [super awakeFromNib]; // Initialization code}-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self =[super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self initUIandMas]; } return self;}-(void)initUIandMas{ __weak typeof(self)wself = self; _contentImage=[[UIImageView alloc]init]; [self.contentView addSubview:_contentImage]; _name=[[UILabel alloc]init]; [self.contentView addSubview:_name]; [_contentImage mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(10); make.left.equalTo(wself.contentView).with.offset(20); make.right.equalTo(wself.contentView).with.offset(-20);// make.bottom.equalTo(_name.mas_top).with.offset(10); make.height.mas_equalTo(100); }]; [_name mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(_contentImage); make.top.equalTo(_contentImage.mas_bottom).with.offset(10); make.height.mas_equalTo(20); make.bottom.equalTo(wself.contentView.mas_bottom).with.offset(-10); }];}-(void)setModel:(myModel *)model{ _name.text=model.name; [_contentImage sd_setImageWithURL:[NSURL URLWithString:model.imageUrl]]; [_contentImage mas_updateConstraints:^(MASConstraintMaker *make) { float height= [model.height floatValue]/[model.width floatValue]*370; make.height.mas_equalTo(height); NSLog(@"height----%f",height); }];}- (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state}@end
0 0
- iOS多种cell使用FDTemplateLayoutCell自动计算高度
- 使用UITableView+FDTemplateLayoutCell计算cell的高度
- cell自动计算高度(masonry与UITableView-FDTemplateLayoutCell)
- UITableView性能优化---自动计算cell高度(FDTemplateLayoutCell)
- iOS 自动计算cell高度
- ios tableview 自动计算cell高度
- 自动计算cell高度
- iOS UITableView-FDTemplateLayoutCell框架 cell重叠 高度返回0.5问题解决
- iOS cell 高度计算
- iOS - 自动计算cell的高度(iOS8 Auto-sizing)
- UITableView自动计算CELL高度
- iOS 自动计算 高度
- Masonry+FDTemplateLayoutCell 实现Cell自动布局
- 基于Masonry自动计算cell的高度
- iOS8之后tableView cell自动计算高度
- UITableView自动计算cell的高度
- UITableView自动计算cell高度并缓存
- UITableView自动计算cell高度并缓存
- 原生ajax异步请求问题--3次握手
- J2EE系列之Struts2学习笔记(七)--struts.xml配置
- 设计模式-策略模式
- 输入+算法+输出
- IPQ4019MTD分区生成的过程
- iOS多种cell使用FDTemplateLayoutCell自动计算高度
- 在github下载的ECharts-GL打开一片黑色
- java23种设计模式理解和练习总结
- Android面试题-oauth认证协议原理
- springboot+dubbo框架下服务注册时不能创建bean对象
- collect.conf
- 关于标题栏颜色随滚动而变换透明度
- 在使用ck编辑器上传中文名的图片报错
- 看得“深”、看得“清” —— 深度学习在图像超清化的应用