Fix deprecation warning — remove traitCollectionDidChange method.

This commit is contained in:
Brent Simmons 2024-11-04 20:21:26 -08:00
parent 4f0cacdd3f
commit 039cc6db2a

View File

@ -73,6 +73,8 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
registerForTraitChanges([UITraitPreferredContentSizeCategory.self], target: self, action: #selector(preferredContentSizeCategoryDidChange))
refreshControl = UIRefreshControl()
refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged)
@ -85,16 +87,13 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
super.viewWillAppear(animated)
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if traitCollection.preferredContentSizeCategory != previousTraitCollection?.preferredContentSizeCategory {
IconImageCache.shared.emptyCache()
reloadAllVisibleCells()
}
}
// MARK: Notifications
@objc func preferredContentSizeCategoryDidChange() {
IconImageCache.shared.emptyCache()
reloadAllVisibleCells()
}
@objc func unreadCountDidChange(_ note: Notification) {
updateUI()