Skip to content

Commit

Permalink
more reliable logic
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoHinderling committed Aug 26, 2024
1 parent b646890 commit 99f5c25
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Sources/SnapshotPreviewsCore/ExpandingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ public final class ExpandingViewController: UIHostingController<EmergeModifierVi

public override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

// Kick off in next run loop cycle to let the layout pass complete first
DispatchQueue.main.async {
self.updateScrollViewHeight()
}
updateScrollViewHeight()
}

public func updateScrollViewHeight() {
Expand All @@ -91,6 +87,11 @@ public final class ExpandingViewController: UIHostingController<EmergeModifierVi
return
}

// Verify scrollview has no pending layout updates
if let firstScrollView = firstScrollView as? UIScrollView {
firstScrollView.layoutIfNeeded()
}

updateHeight {
runCallback()
}
Expand Down

0 comments on commit 99f5c25

Please sign in to comment.