Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout
18.06k
stars
3.15k
forks
source link
Custom cell placed above two UILabel variable number of rows can not show the entire content on iphone5s ios8.4 #500
Open
wuyuqiu opened 6 years ago
New Issue Checklist
🚫 If this template is not filled out your issue will be closed with no comment. 🚫
Issue Info
![Uploading Simulator Screen Shot - iPhone 5s - 2017-12-19 at 18.51.59.png…]()
Platform Version | e.g. 8.4 Masonry Version | e.g. 1.1.0 Integration Method | e.g. carthage/cocoapods/manually
Issue Description
⚠️ Custom cell placed above two UILabel variable number of rows can not show the entire content
TableView code :
-(UITableView *)tableView { if (_tableView==nil) { _tableView = [[TableView alloc] init]; _tableView.delegate=self; _tableView.dataSource=self; _tableView.estimatedRowHeight =49; _tableView.tableFooterView = [UIView new]; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; } return _tableView; }
Custom tableViewCell code like this: // // AutoTableViewCell.m // AutoTableView //
import "AutoTableViewCell.h"
import "RowsModel.h"
@interface AutoTableViewCell ()
@property (nonatomic, strong) UILabel title_label; @property (nonatomic, strong) UILabel detail_label;
@end
@implementation AutoTableViewCell
(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self.contentView addSubview:self.title_label]; [self.contentView addSubview:self.detail_label];
} return self; }
(NSString *)identifier { return @"AutoTableViewCellIdentifier"; }
(void)awakeFromNib { [super awakeFromNib]; // Initialization code }
(void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated];
// Configure the view for the selected state }
pragma mark - setter
(void)setModel:(RowsModel *)model { _model = model; if (_model) { // do someting... _title_label.text = _model.title; _detail_label.text = _model.details; } }
pragma mark - getter
(UILabel *)title_label { if (!_title_label) { _title_label = [UILabel new]; _title_label.numberOfLines = 0; _title_label.textColor = [UIColor blackColor]; } return _title_label; }
(UILabel *)detail_label { if (!_detail_label) { _detail_label = [UILabel new]; _detail_label.numberOfLines = 0; _detail_label.textColor = [UIColor grayColor]; } return _detail_label; }
pragma mark - autolayout
(void)makeMasConstraints {
[self.title_label mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView.mas_top).offset(10); make.left.equalTo(self.contentView.mas_left).offset(10); make.right.equalTo(self.contentView.mas_right).offset(-10); }];
[self.detail_label mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.title_label.mas_bottom).offset(5); make.left.equalTo(self.contentView.mas_left).offset(10); make.right.equalTo(self.contentView.mas_right).offset(-10); make.bottom.equalTo(self.contentView.mas_bottom).offset(-10); }]; }
@end ⚠️