Body font dynamic sizing ignored in cell labels

For all my apps that use table view cells, I set up the textLabel and detailTextLabel in the storyboard editor to have a font of 'Body'. And, as my minimum OS is iOS 11, I also check the 'Automatically Ajusts Font' checkbox.


When building these apps with Xcode 10.3 against the iOS 12 SDK, the apps react to dynamic type changes automatically as expected.


But, when building the same apps with Xcode 11 (release version) against the iOS 13 SDK, the apps no longer work. All labels in table view cells have a fixed size. Even when the app is launched with various settings of the system's text size already set up.


Standalone labels though work a-ok (same font and automatically... settings used).


If I inspect the label's attributes at runtime, they do indeed have the 'adjustsFontForContentSizeCategory' set to 'true'. The font property appears "OK":


- some : <UICTFont: 0x7f96d5c20440> font-family: "UICTFontTextStyleBody";
font-weight: normal; font-style: normal; font-size: 17.00pt


To remedy this, I created a sublass of UITableViewCell and in its awakeFromNib, I programatically set the font:


let theFont = UIFont.preferredFont(forTextStyle: .body)
textLabel?.font = theFont
detailTextLabel?.font = theFont


If I inspect the attributes with this workaround, the adjustsFontForContentSizeCategory is still set to 'true' (so matches what I set in IB). The font property with dynamic text set to the default value is:


- some : <UICTFont: 0x7fb78dd198a0> font-family: "UICTFontTextStyleBody";
font-weight: normal; font-style: normal; font-size: 17.00pt


Other than the memory address difference, they are identical. Yet the behavior isn't the same. So there must be something behind the scenes that isn't being set up correctly when just relying on the settings in IB.


NOTE: While I didn't try all fonts, the same issue doesn't happen with 'Callout'. I'll file a bug after I test all the other fonts to see if this is perhaps just isolated to 'Body'.

Accepted Reply

Just updated my sample app with Xcode 11.1, and can no longer reproduce the issue.

Replies

Filed bug: FB7324278


The issue only happes with the Body font style. If your textLabel or detailTextLabel uses any other style (Subhead, Callout, etc.), then dynamic text changes are honored.


Still unknown if this is an issue in how Xcode is generating code, or if its in iOS itself. This bug occurs in apps running on both iOS 13 and 13.1 (release versions).

I noticed the same thing. I have a caption1 label and it doesn't work there either, so I think it's more than the body style. If I reset the font in my `tableView(_,cellForRowAt:)` function, then it works.


cell.textLabel?.font = UIFont.preferredFont(forTextStyle: .body) 
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .caption1)

Just updated my sample app with Xcode 11.1, and can no longer reproduce the issue.

Everything still works with Xcode 11.2.1 GM (skipping testing of 11.2 due to the UITextView bug). So it appears that Xcode is now generating proper code once again regarding this issue.