Ecco il frammento di codicePerché systemLayoutSizeFittingSize restituisce (0, 0) per 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));
}];
Nel controller della vista, che utilizza 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;
}
Questa restituisce sempre 1.f. Per favore aiuto e non sono sicuro di cosa sto facendo male qui.
Questo ha molto senso. Ma ancora non funziona :(. Ho aggiunto questo: make.top.equalTo (@ 0); – mobjug
Uh-huh. Hai letto quello che ho detto? Devi _pin_ il primo e il fondo della vista dell'immagine _al contenuto view_. Non l'hai fatto. Non posso aiutarti se non ascolti. – matt
OK Avevo perso il fondo. Grazie – mobjug