TestModel数据模型
TestModel.h
@property(nontomic,copy)NSString *name;
@property(nontomic,copy)NSString *headerIcon;
@property(nontomic,copy)NSString *content;
FrameModel
FrameModel.h
@property(nontomic,assign)CGRect nameLabelFrame;
@property(nontomic,assign)CGRect headerIconFrame;
@property(nontomic, assign)CGRect contentLabelFrame;
@property(nontomic, strong)TestModel *testModel;
@property(nontomic, assign)CGFloat cellHeight;
根据数据模型计算各个控件的Frame
-(void)setTestModel:(TestModel*)testModel
{
_testModel = _testModel;
_nameLabelFrame = ....
_headerIconFrame = ....
_contentLabelFrame = ....
_cellHeight = ....
}
TestCell
TestCell.h
//控件...
@property(nontomic, strong)FrameModel *frameModel;
TestCell.m
- initWithStyle: identify
{
if(self = [super init....])
{
self.contentView addSubView:...
}
}
-(void)setFrameModel:(FrameModel*)frameModel
{
_frameModel = frameModel;
//设置数据
self.nameLabel.text = frameModel.testModel.name;
...........
//设置Frame
self.nameLabel.frame = frameModel.nameFrame;
...........
}
VC
加载完数据
此时数据原数组里应该存放的是FrameModel
-loadData
{
for(...;....;.....){
TestModel *testModel = ..........
FrameModel *fameModel = [[FrameModel alloc]init];
frameModel.testModel = testModel;
[_dataArray addObj:frameModel]
}
}
- heightForRowAtIndexPath
{
FrameModel *frameModel = _dataArray[indexPath.row];
return frameModel.cellHeight;
}
-cellForRowAtIndexPath
{
....
cell.frameModel = _dataArray[indexPath.row];
}