systemLayoutSizeFittingSizeの高さが0になる

こんな感じのコードをウッカリ書いてしまって、セルの高さがゼロになってしまうミスをちょくちょくやらかすので、自分用にメモ。

UITableViewCell *cell = _calculationCell;
return [cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;

上のような書き方ではなく、次のようにcontentViewに対してsystemLayoutSizeFittingSizeを実行する

UITableViewCell *cell = _calculationCell;
return [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;

◯ Chapter 06がAutoLayout

Pocket
LINEで送る
LinkedIn にシェア