mob*_*jug 13 uitableview ios autolayout
这是代码片段
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));
}];
Run Code Online (Sandbox Code Playgroud)
在视图控制器中,它使用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;
}
Run Code Online (Sandbox Code Playgroud)
这总是返回1.f. 请帮助,我不知道我在这里做错了什么.
mat*_*att 30
问题是你的约束不是细胞高度的决定因素.您尚未将图像视图的顶部或图像视图的底部固定到其超视图(contentView).因此,当你打电话时,单元格没有内部任何东西可以防止它一直崩溃到零systemLayoutSizeFittingSize.
换句话说:systemLayoutSizeFittingSize工作方式是将某些内部约束视为支撑,使其具有最小(或最大)尺寸.你没有支柱.
| 归档时间: |
|
| 查看次数: |
9174 次 |
| 最近记录: |