スクロール、私はセルの高さと各indexPathのViewControllerでテーブルビュー
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
PFBubbleData *dataModel = (PFBubbleData *)self.dataSource[indexPath.row];
PFBubbleLayout *layout = dataModel.layout;
return layout.bubbleHeight;
}
での行の設定dynamitcの高さをキャッチしてからセルを取得するときに、レイアウトがミックスです
(各サブビューはすでにので、ここで、getMethodで作成した直接サブビューを追加)、contentViewにサブビューを追加し、セルを作成するときに、セルキューデータモデルの魔女との更新には、レイアウトモデルに-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
PFBubbleCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PFBubbleCell"];
[cell updateViewWithData:self.dataSource[indexPath.row]];
return cell;
}
が含まれています
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
LOG_METHOD
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.contentView.translatesAutoresizingMaskIntoConstraints = NO;
self.contentView.backgroundColor = [UIColor colorWithRed:0.224 green:0.671 blue:1.000 alpha:1.000];
[self.contentView addSubview:self.faceImageView];
[self.contentView addSubview:self.containerView];
}
return self;
}
最後に、私はときに私のセットアップデータモデルのセルにサブビューを更新し、石工レイアウトサブビューに
-(void)updateViewWithData:(id)dataEntity {
LOG_METHOD
self.dataModel = (PFBubbleData*)dataEntity;
//update the subeViewFrame is Needed after the data changed
[self.faceImageView setImage:self.dataModel.avatarImage];
[self setupFrameAndConstraints];
}
を使用石工のレイアウトが、それはこのように表示され
-(void)setupFrameAndConstraints {
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self).insets(UIEdgeInsetsMake(0, 0, 0, 0));
}];
if (self.dataModel.bubbleDirection == PFBubbleDirection_Other) {
// self.avaterImageView.frame = CGRectMake(self.dataModel.layout.board_margin,
// self.dataModel.layout.board_margin, 50, 50);
// self.containerView.frame = CGRectMake(CGRectGetMaxX(self.avaterImageView.frame) + self.dataModel.layout.board_margin,
// CGRectGetMinY(self.avaterImageView.frame),
// self.dataModel.layout.contentSize.width,
// self.dataModel.layout.contentSize.height);
[self.faceImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView.mas_top).offset(contentMargin);
make.left.equalTo(self.contentView.mas_left).offset(contentMargin);
make.width.mas_equalTo(@(50));
make.height.mas_equalTo(@(50));
}];
[self.containerView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.faceImageView.mas_top);
make.left.equalTo(self.faceImageView.mas_right).offset(contentMargin);
make.width.mas_equalTo(self.dataModel.layout.contentSize.width);
make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-contentMargin);
}];
}else if(self.dataModel.bubbleDirection == PFBubbleDirection_Self){
// self.avaterImageView.frame = CGRectMake(self.frame.size.width - self.dataModel.layout.board_margin - 50,
// self.dataModel.layout.board_margin, 50, 50);
//
// self.containerView.frame = CGRectMake(CGRectGetMinX(self.avaterImageView.frame) - self.dataModel.layout.board_margin - self.dataModel.layout.contentSize.width,
// CGRectGetMinY(self.avaterImageView.frame),
// self.dataModel.layout.contentSize.width,
// self.dataModel.layout.contentSize.height);
[self.faceImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView.mas_top).offset(contentMargin);
make.right.equalTo(self.contentView.mas_right).offset(-contentMargin);
make.width.mas_equalTo(@(50));
make.height.mas_equalTo(@(50));
}];
[self.containerView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.faceImageView.mas_top);
make.right.equalTo(self.faceImageView.mas_left).offset(-contentMargin);
make.width.mas_equalTo(self.dataModel.layout.contentSize.width);
make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-contentMargin);
}];
}
[self setNeedsLayout];
[self layoutIfNeeded];
}
テーブルをスクロールするとログが表示される