Skip to content

Commit

Permalink
Merge pull request #81 from iZettle/fix-scrollview-install-layout-bug…
Browse files Browse the repository at this point in the history
…-on-iOS-10

Activate constraints before calls to layoutIfNeeded to prevent crashes on iOS 9/10
  • Loading branch information
nataliq-pp authored Jan 29, 2019
2 parents 16e879d + feff130 commit f2a0f89
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Form/UIScrollView+Spacing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public extension UIScrollView {
bottom.constant = $0
}

// The added constraints need to be activated before any calls to `layoutIfNeeded` because the layout might be unsatisfiable otherwise
activate(constraints)
disembedBag += { deactivate(constraints) }

// .equalSpacing gives ambigious layout on iOS < 11, help out by calculating spacing manually.
if #available(iOS 11, *) {} else if orderedViews.count > 0 {
let contentHeight = signal(for: \.contentSize)[\.height].toVoid().atValue {
Expand All @@ -73,9 +77,6 @@ public extension UIScrollView {
}
}

activate(constraints)
disembedBag += { deactivate(constraints) }

return bag
}
}

0 comments on commit f2a0f89

Please sign in to comment.