Dưới đây là đoạn mãTại sao systemLayoutSizeFittingSize trả lại (0, 0) cho UITableViewCell?
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));
}];
Trong bộ điều khiển xem, trong đó sử dụng 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;
}
này luôn trả về 1.f. Xin vui lòng giúp đỡ và tôi không chắc chắn những gì tôi đang làm sai ở đây.
Điều đó có ý nghĩa rất nhiều. Nhưng nó vẫn không hoạt động: (Tôi đã thêm điều này: make.top.equalTo (@ 0); – mobjug
Uh-huh Bạn đã đọc những gì tôi đã nói chưa? Bạn phải _pin_ đầu _and_ phần dưới cùng của chế độ xem hình ảnh vào nội dung view_ Bạn không làm điều đó Tôi không thể giúp bạn nếu bạn không nghe – matt
OK Tôi đã bỏ lỡ phía dưới Cảm ơn bạn – mobjug