Digital PCT265 defect CXTDT-579050: Prevent updateViews from triggering tableView(_:cellForRowAt:) through visibleCells.

This commit is contained in:
Hedden, Kyle Matthew 2024-06-28 15:23:17 -04:00
parent 3cdd74f097
commit 91eb4fa87a
2 changed files with 12 additions and 2 deletions

View File

@ -52,8 +52,8 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController, Rotor
bottomView.updateView(width) bottomView.updateView(width)
showFooter(width) showFooter(width)
} }
tableView.visibleCells.forEach { cell in MVMCoreUIUtility.findParentViews(by: (UITableViewCell & MVMCoreViewProtocol).self, views: tableView.subviews).forEach { view in
(cell as? MVMCoreViewProtocol)?.updateView(width) view.updateView(width)
} }
} }

View File

@ -60,6 +60,16 @@ public extension MVMCoreUIUtility {
return findViews(by: type, views: queue, excludedViews: excludedViews) + matching return findViews(by: type, views: queue, excludedViews: excludedViews) + matching
} }
static func findParentViews<T>(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 @MainActor
static func visibleNavigationBarStlye() -> NavigationItemStyle? { static func visibleNavigationBarStlye() -> NavigationItemStyle? {
if let navController = NavigationController.navigationController(), if let navController = NavigationController.navigationController(),