以下是代码段
self.xyzIcon = [UIImage mobileImageNamed:@"icon_xyz"]; self.xyzIconImageView = [UIImageView new]; [self.contentView addSubview:self.xyzIconImageView]; [self.xyzIconImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.contentView.mas_left); make.width.equalTo(@(weakSelf.xyzIcon.size.width)); make.height.equalTo(@(weakSelf.xyzIcon.size.height)); }];
在视图控制器中,它使用tableview
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (!self.prototypeCell) { self.prototypeCell = [UITableViewCell new]; } [self.prototypeCell configure]; CGFloat heightCalculated = [self.prototypeCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height + 1.f; NSLog(@"Height calculated %f",heightCalculated); returns heightCalculated; }
这总是返回1.f.请帮忙,我不知道我在这里做错什么.