🤖

UITableViewCellの高さが常に一定の時はrowHeightを使う

2021/12/29に公開
self.tableView.rowHeight = 44.0f;

みたいに書く。

高さ可変のケースが多いから、他からコピペしてきて

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  return 44.0f;
}

とか書いてしまうけど、これは無駄。

セルが100個あったら、100回heightForRowAtIndexPath呼ばれるから。

Discussion