UITableView showing static cells with standard styles loses content when Dynamic Type font size is changed

Originator:argentumko
Number:rdar://22008452 Date Originated:27-Jul-2015
Status:Duplicate of 17963356 (Open) Resolved:
Product:iOS SDK Product Version:iOS 8.0+
Classification:UI/Usability Reproducible:Always
 
Summary:
Launching an app that displays a UITableView with static cells (managed by a UITableViewController inside a storyboard) with non-custom styles (UITableViewCellStyleDefault, UITableViewCellStyleValue1, etc.), then changing Dynamic Type font size while that app is running, makes these static cells completely lose their content.

This issue is related to the "automatic Dynamic Type support" added into UITableViewCell in iOS 8. UITableViewCell with one of the standard styles internally observes the Dynamic Type font size change notification, and when it is posted, *removes* its textLabel and detailTextLabel from itself. This usually doesn't cause issues, since UITableView with dynamic content usually causes a data reload to be performed afterwards, which makes the table data source to re-set content on cell labels – recreating these labels on demand. However, this does not happen with static tables since static cells are created all at once and do not change. As a result, labels are removed but are not recreated.

Steps to Reproduce:
1. Create an app containing a storyboard with UITableViewController managing a static table.
2. Add a few cells into the static table, setting the style of those cells to one of standard ones (UITableViewCellStyleDefault, UITableViewCellStyleValue1, etc.)
3. Launch the app and display the static table.
4. Switch to the Settings app.
5. Go to Dynamic Type settings and change the font size.
6. Switch back into the app.

Expected Results:
Static table keeps its content; cells adjust the font size of their labels according to the changed Dynamic Type setting.

Actual Results:
Static table becomes empty, all labels from the cells are completely gone.

Version:
iOS 8.0 and newer, including iOS 9 beta 4

Notes:
A workaround for this issue is to use a subclass of UITableViewCell for static cells, which manually removes the base implementation from observing Dynamic Type notifications and adds custom handling of these.

Attached project demonstrates the issue using a simple storyboard.

This issue can also occasionally manifest itself in dynamic cells, but exact steps to reproduce that were not found. Theoretically, that's caused by table reload not being performed.

Configuration:
Any hardware or simulator

Attachments:
'DynamicTypeTableCells.zip' was successfully uploaded.

Comments

Vlas Voloshin

As of iOS 9.3 beta 2, static tables ignore Dynamic Type, which might not be the best solution to the problem. Additionally, changing Dynamic Type size causes the app to emit the following warning log into console: bogus value for UIPreferredContentSizeCategoryName: (null)

By argentumko at Jan. 26, 2016, 8:29 a.m. (reply...)

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!