自適應(yīng)布局很是讓人頭疼强岸,解決了布局沖突之后蝌箍,還有一個(gè)打印警告妓盲。望各位大神賜教专普。
警告內(nèi)容:[LayoutConstraints] Changing the translatesAutoresizingMaskIntoConstraints property of the contentView of a UITableViewCell is not supported and will result in undefined behavior, as this property is managed by the owning UITableViewCell. Cell:
下面是代碼cell代碼。
@implementationManagerShippingAddressCell
- (void)awakeFromNib {
? ? [super awakeFromNib];
? ? // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier {
? ? self= [superinitWithStyle:style
? ? ? ? ? ? ? ? reuseIdentifier:reuseIdentifier];
? ? if(self) {
? ? ? ? self.selectionStyle = UITableViewCellSelectionStyleNone;
? ? ? ? [self initContentViewsWithSubV];
? ? }
? ? return self;
}
- (void)initContentViewsWithSubV {
? ? self.contentView.backgroundColor = [UIColor whiteColor];
? ? [self.contentView addSubview:self.nameLabel];
? ? [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? make.top.mas_equalTo(self.contentView.mas_top).mas_offset(adaptX(20));
? ? ? ? make.left.mas_equalTo(self.contentView.mas_left).mas_offset(adaptX(15));
? ? ? ? make.height.mas_equalTo(adaptX(15)).priority(700);
? ? ? ? make.width.mas_equalTo(adaptX(200));
? ? }];
? ? [self.contentView addSubview:self.phoneNumNote];
? ? [self.phoneNumNote mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? make.top.mas_equalTo(self.nameLabel.mas_bottom).mas_offset(adaptX(15));
? ? ? ? make.left.mas_equalTo(self.nameLabel.mas_left);
? ? ? ? make.height.mas_equalTo(adaptX(13)).priority(500);
? ? ? ? make.width.mas_equalTo(adaptX(58));
? ? }];
? ? [self.contentView addSubview:self.phoneNumLabel];
? ? [self.phoneNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? make.top.mas_equalTo(self.phoneNumNote.mas_top);
? ? ? ? make.left.mas_equalTo(self.phoneNumNote.mas_right);
? ? ? ? make.width.mas_equalTo(adaptX(100));
? ? ? ? make.height.mas_equalTo(adaptX(13)).priority(500);
? ? }];
? ? [self.contentView addSubview:self.shippingAddressNote];
? ? [self.shippingAddressNote mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? make.top.mas_equalTo(self.phoneNumNote.mas_bottom).mas_offset(adaptX(10));
? ? ? ? make.left.mas_equalTo(self.phoneNumNote.mas_left);
? ? ? ? make.height.mas_equalTo(adaptX(13)).priority(500);
? ? ? ? make.width.mas_equalTo(adaptX(58));
? ? }];
? ? [self.contentView addSubview:self.shippingAddressLabel];
? ? [self.shippingAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? make.top.mas_equalTo(self.shippingAddressNote.mas_top);
? ? ? ? make.left.mas_equalTo(self.shippingAddressNote.mas_right);
? ? ? ? make.width.mas_equalTo(250);
? ? ? ? make.bottom.mas_equalTo(self.contentView.mas_bottom).mas_offset(-adaptX(50)).priority(500);
? ? }];
? ? [self.contentView addSubview:self.bottomContentView];
? ? [self.bottomContentView mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? make.left.right.bottom.mas_equalTo(self.contentView);
? ? ? ? make.height.mas_equalTo(adaptX(45));
? ? }];
? ? [self.bottomContentView addSubview:self.setDefaultBtn];
? ? [self.setDefaultBtn mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? make.left.mas_equalTo(self.bottomContentView.mas_left).mas_offset(adaptX(15));
? ? ? ? make.height.mas_equalTo(adaptX(15));
? ? ? ? make.width.mas_equalTo(adaptX(70));
? ? ? ? make.centerY.mas_equalTo(self.bottomContentView.mas_centerY);
? ? }];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
? ? [supersetSelected:selectedanimated:animated];
? ? // Configure the view for the selected state
}
- (void)cellWithModel:(ShippingAddressModel*)addressModel {
? ? self.nameLabel.text= addressModel.name;
? ? self.phoneNumLabel.text= addressModel.phoneNum;
? ? self.shippingAddressLabel.text= [NSStringstringWithFormat:@"%@%@%@", addressModel.location, addressModel.location, addressModel.location];
? ? self.setDefaultBtn.selected = addressModel.defaultAddress;
? ? [self layoutIfNeeded];
}
- (UILabel*)nameLabel {
? ? if (!_nameLabel) {
? ? ? ? _nameLabel= [[UILabelalloc]init];
? ? ? ? _nameLabel.font = kFontName(@"PingFangSC-Medium", 16);
? ? ? ? _nameLabel.textColor=UIColorFromRGB(0x111111);
? ? ? ? _nameLabel.text=@"大橙子";
? ? ? ? _nameLabel.textAlignment = NSTextAlignmentLeft;
? ? }
? ? return _nameLabel;
}
- (UIButton*)setDefaultBtn {
? ? if (!_setDefaultBtn) {
? ? ? ? _setDefaultBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//? ? ? ? _setDefaultBtn.frame = CGRectMake(kScreenWidth - adaptX(85), adaptX(20), adaptX(70), adaptX(15));
? ? ? ? [_setDefaultBtn setTitle:@"默認(rèn)地址" forState:UIControlStateNormal];
? ? ? ? [_setDefaultBtn setTitleColor:UIColorFromRGB(0xFF8135) forState:UIControlStateNormal];
? ? ? ? _setDefaultBtn.titleLabel.font = kFontName(@"PingFangSC-Regular", 12);
? ? ? ? //? ? ? ? _setDefaultBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
? ? ? ? //? ? ? ? _setDefaultBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
? ? ? ? [_setDefaultBtn lz_updateImageAlignmentSystemLeftWithSpace:adaptX(5)];
? ? ? ? [_setDefaultBtn setImage:[UIImage imageNamed:@"set_Default_selected"] forState:UIControlStateNormal];
? ? }
? ? return _setDefaultBtn;
}
- (UILabel*)phoneNumNote {
? ? if (!_phoneNumNote) {
? ? ? ? _phoneNumNote= [[UILabelalloc]init];
? ? ? ? _phoneNumNote.font = kFontName(@"PingFangSC-Regular", 13);
? ? ? ? _phoneNumNote.textColor=UIColorFromRGB(0x999999);
? ? ? ? _phoneNumNote.text = @"手機(jī)號(hào) :";
? ? ? ? _phoneNumNote.textAlignment = NSTextAlignmentRight;
? ? }
? ? return _phoneNumNote;
}
- (UILabel*)phoneNumLabel {
? ? if (!_phoneNumLabel) {
? ? ? ? _phoneNumLabel= [[UILabelalloc]init];
? ? ? ? _phoneNumLabel.font = kFontName(@"PingFangSC-Regular", 13);
? ? ? ? _phoneNumLabel.textColor=UIColorFromRGB(0x111111);
? ? ? ? _phoneNumLabel.text = @"155-1123-1355";
? ? ? ? _phoneNumLabel.textAlignment = NSTextAlignmentLeft;
? ? }
? ? return _phoneNumLabel;
}
- (UILabel*)shippingAddressNote {
? ? if (!_shippingAddressNote) {
? ? ? ? _shippingAddressNote = [[UILabel alloc] init];
? ? ? ? _shippingAddressNote.font = kFontName(@"PingFangSC-Regular", 13);
? ? ? ? _shippingAddressNote.textColor = UIColorFromRGB(0x999999);
? ? ? ? _shippingAddressNote.text = @"收貨地址:";
? ? ? ? _shippingAddressNote.textAlignment = NSTextAlignmentRight;
? ? }
? ? return _shippingAddressNote;
}
- (UILabel*)shippingAddressLabel {
? ? if (!_shippingAddressLabel) {
? ? ? ? _shippingAddressLabel = [[UILabel alloc] init];
? ? ? ? _shippingAddressLabel.font = kFontName(@"PingFangSC-Regular", 13);
? ? ? ? _shippingAddressLabel.textColor = UIColorFromRGB(0x111111);
? ? ? ? _shippingAddressLabel.preferredMaxLayoutWidth = adaptX(250);
? ? ? ? _shippingAddressLabel.numberOfLines = 0;
? ? ? ? _shippingAddressLabel.text = @"北京市海淀區(qū) 彩和坊路9號(hào) 1+1大廈";
? ? ? ? _shippingAddressLabel.textAlignment = NSTextAlignmentLeft;
? ? }
? ? return _shippingAddressLabel;
}
- (UIView*)bottomContentView {
? ? if (!_bottomContentView) {
? ? ? ? _bottomContentView = [[UIView alloc] init];
? ? ? ? _bottomContentView.userInteractionEnabled = YES;
? ? ? ? _bottomContentView.backgroundColor = UIColorFromRGB(0xF6F7FA);
? ? }
? ? return _bottomContentView;
}
@end