diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index 4bd889bd..c85e7b85 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -52,8 +52,8 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController, Rotor bottomView.updateView(width) showFooter(width) } - tableView.visibleCells.forEach { cell in - (cell as? MVMCoreViewProtocol)?.updateView(width) + MVMCoreUIUtility.findParentViews(by: (UITableViewCell & MVMCoreViewProtocol).self, views: tableView.subviews).forEach { view in + view.updateView(width) } } diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift index ea91f62b..5b70412e 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift +++ b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift @@ -60,6 +60,16 @@ public extension MVMCoreUIUtility { return findViews(by: type, views: queue, excludedViews: excludedViews) + matching } + static func findParentViews(by type: T.Type, views: [UIView]) -> [T] { + return views.reduce(into: [T]()) { matchingViews, view in + if let view = view as? T { + return matchingViews.append(view) // If this view is the type stop here and return, ignoring its children. + } + // Otherwise check downstream. + matchingViews += findParentViews(by: type, views: view.subviews) + } + } + @MainActor static func visibleNavigationBarStlye() -> NavigationItemStyle? { if let navController = NavigationController.navigationController(),