UIListContentConfiguration.subtitleCell layout does not match UIListContentConfiguration.cell configured with secondaryText

Number:rdar://FB9197862 Date Originated:June 21, 2021
Status:Open Resolved:
Product:iOS Product Version:14
Classification:Bug Reproducible:Yes
UIListContentConfiguration.subtitleCell() does not result in cell layout that is consistent with UITableViewCellStyleSubtitle.

# What we expect


# What we see


# Reproduction steps

Consider the following simple reproduction case:

let cellConfig = UIListContentConfiguration.cell()
let subtitleConfig = UIListContentConfiguration.subtitleCell()


This outputs the following:

<UIListContentConfiguration: 0x6000012ad8f0; Base Style = Cell; directionalLayoutMargins = {11, 16, 11, 8}; axesPreservingSuperviewLayoutMargins = [Horizontal]; imageToTextPadding = 16; textToSecondaryTextVerticalPadding = 3>
<UIListContentConfiguration: 0x6000012adab0; Base Style = Subtitle Cell; directionalLayoutMargins = {4, 16, 4, 8}; axesPreservingSuperviewLayoutMargins = [Horizontal]; imageToTextPadding = 16; textToSecondaryTextVerticalPadding = 0>

Note that directionalLayoutMargins and textToSecondaryTextVerticalPadding do not match between both styles.

The attached screenshots cell.png and subtitleCell.png show the unexpected difference in layout behavior.

The subtitleCell configuration results in a significantly more dense layout than when using `cell` config. This incorrect behavior affects both UICollectionView and UITableView cells using contentConfiguration, as would be expected because the bug is in the UIListContentConfiguration implementation.

# Why this feels like a problem

Comparing this behavior to the legacy, non-contentConfiguration UITableView APIs (i.e. assigning values to textLabel and detailTextLabel directly), you get tableView-Subtitle-expected.png, which has the expected padding around the content. The following code snippet was used to create the tableView-Subtitle-expected.png screenshot.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
  cell.textLabel.text = [NSString stringWithFormat:@"Hello %@", @(indexPath.row)];;
  cell.detailTextLabel.text = [NSString stringWithFormat:@"Hello %@", @(indexPath.row)];
  return cell;

# Some work-arounds

We're exploring two work-arounds:

1. Only use UIListContentConfiguration.cell()
2. Provide a fixed version of UIListContentConfiguration.subtitleCell() that copies the mis-configured values from UIListContentConfiguration.cell().

UIListContentConfiguration *correctConfig = [UIListContentConfiguration cellConfiguration];
UIListContentConfiguration *config = [UIListContentConfiguration subtitleCellConfiguration];
config.directionalLayoutMargins = correctConfig.directionalLayoutMargins;
config.textToSecondaryTextVerticalPadding = correctConfig.textToSecondaryTextVerticalPadding;


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!