Skip to content

Commit be35f31

Browse files
committed
Reset Auto Layout constraint that pins to a view that is being removed to fix a crash.
1 parent a1acb44 commit be35f31

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/DashboardViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,12 @@ private extension DashboardViewController {
543543
return
544544
}
545545

546+
// Resets the Auto Layout constraint that pins the previous content view to the bottom of the header view.
547+
// Otherwise, if `contentTopToHeaderConstraint?.isActive = true` is called after the previous content view is removed
548+
// in the next line `remove(previousDashboardUI)`, the app crashes because the content view is no longer in the
549+
// view hierarchy.
550+
contentTopToHeaderConstraint = nil
551+
546552
// Tears down the previous child view controller.
547553
if let previousDashboardUI = dashboardUI {
548554
remove(previousDashboardUI)

0 commit comments

Comments
 (0)