Skip to content

Commit

Permalink
Make window optional in ViewPortState prevent crashes in iOS 15 (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
moglistree authored Oct 8, 2021
1 parent ca9b0ec commit 04d3e83
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Form/ViewPortEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public extension UIView {
private class ViewPortState {
weak var window: UIWindow? // Not keeping strong reference to the window to avoid UIWindow leaks
let bag = DisposeBag()
init(window: UIWindow) {
init(window: UIWindow?) {
self.window = window
bag += Form.keyboardSignal().onValue { _ in } // Make sure to setup listener so keyboardFrame will be updated
}
Expand All @@ -73,7 +73,7 @@ private extension UIView {
}

let app = UIApplication.shared
let window = self.window ?? (self as? UIWindow) ?? app.keyWindow ?? app.windows.first!
let window = self.window ?? (self as? UIWindow) ?? app.keyWindow ?? app.windows.first
return associatedValue(forKey: &viewPortKey, initial: ViewPortState(window: window))
}
}

0 comments on commit 04d3e83

Please sign in to comment.