From 039cc6db2a0a5ce7068124653354cefcc30868e7 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 4 Nov 2024 20:21:26 -0800 Subject: [PATCH] =?UTF-8?q?Fix=20deprecation=20warning=20=E2=80=94=20remov?= =?UTF-8?q?e=20traitCollectionDidChange=20method.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS/MasterFeed/MasterFeedViewController.swift | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 9851a617b..db42ab424 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -71,7 +71,9 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { NotificationCenter.default.addObserver(self, selector: #selector(feedIconDidBecomeAvailable(_:)), name: .FeedIconDidBecomeAvailable, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(feedSettingDidChange(_:)), name: .FeedSettingDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, 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) @@ -84,17 +86,14 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { updateUI() 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()