Why is -tableView: heightForRowAtIndexPath: a delegate method instead of a data source method?

I found that this method is a delegate method of a UITableView:

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

I'm really confused, why is this not a data source method?

+4
source share
2 answers

This answer gives a good overview of the rough separation between methods UITableViewDataSourceand UITableViewDelegate: The difference between UITableViewDelegate and UITableViewDatasource

In this case, heightForRowAtIndexPath has more in common with the UITableView layout than with the contents in individual cells, so it was grouped with delegate methods (although cell contents and height can often be very large related)

+1

-tableView heightForRowAtIndexPath . . . , , UITableViewDelegate.

0

Source: https://habr.com/ru/post/1619294/


All Articles