以下是代码段
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.请帮忙,我不知道我在这里做错什么.
解决方法
问题是您的约束不能决定单元格的高度.您尚未将图像视图的顶部或图像视图的底部固定到其超视图(contentView).因此,当您调用systemLayoutSizeFittingSize时,单元格没有任何内部的内容,以防止它一直崩溃.
换句话说:systemLayoutSizeFittingSize的作用是将某些内部约束视为一个最小(或最大)大小的struts.你没有支柱
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。