This is a terrible hackish workaround that will probably bite me later but somehow it fixed all my Dynamic Text issues (iOS 11). As long as iOS doesn't use UIContentSizeCategoryDidChangeNotification for anything else on UITableView, this workaround shouldn't break anything.
For anybody that wants to add this to their table view collection subclass (Swift 4, iOS 11):
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.removeObserver(tableView!, name: .UIContentSizeCategoryDidChange, object: nil)
}
(or add line 3 to your overriding implementation of viewDidLoad())
I'm performing manual font changes in prepareForReuse() of the custom table view cell class. By reloading the table view, the changes are applied to the cells. Add this to your view controller subclass to reload your cells (or do other work):
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if self.traitCollection.preferredContentSizeCategory != previousTraitCollection?.preferredContentSizeCategory {
tableView?.reloadData()
}
}
Thank you very much — you spared me hours of work! 🙂