美文网首页
UITableView+FDTemplateLayoutCell

UITableView+FDTemplateLayoutCell

作者: 姚姚先生 | 来源:发表于2018-05-04 08:58 被阅读43次

注意点 1

指定最下面view的bottom约束,这样才能够确切的计算出Cell的高度。


[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {   
 make.left.equalTo(self.iconView);
 make.top.equalTo(self.iconView.bottom).with.offset(10); 
 make.right.equalTo(-10);
 make.bottom.equalTo(-10); //重要 
}];

注意点 2

iOS7设备上Cell默认高度44的约束冲突
<NSLayoutConstraint UITableViewCellContentView.height == 44>
需要在Cell初始化的时候设置contentView的autoresizingMask值

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 
{
         self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
          if (self)
              {
                self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
              }
        return self;
}

相关文章

网友评论

      本文标题:UITableView+FDTemplateLayoutCell

      本文链接:https://www.haomeiwen.com/subject/hoirrftx.html