Skip to content

Commit

Permalink
fix invalid safearea insets in a table view with static cells
Browse files Browse the repository at this point in the history
See also #330
  • Loading branch information
scenee committed May 15, 2020
1 parent 5787a35 commit 80ec646
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Framework/Sources/FloatingPanelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,10 @@ open class FloatingPanelController: UIViewController {
// 2. The safe area top inset can be variable on the large title navigation bar(iOS11+).
// That's why it needs the observation to keep `adjustedContentInsets` correct.
safeAreaInsetsObservation = self.view.observe(\.safeAreaInsets, options: [.initial, .new, .old]) { [weak self] (_, change) in
guard change.oldValue != change.newValue, let newValue = change.newValue else { return }
self?.update(safeAreaInsets: newValue)
// Use `self.view.safeAreaInsets` becauese `change.newValue` can be nil in particular case when
// is reported in https://github.com/SCENEE/FloatingPanel/issues/330
guard let self = self, change.oldValue != self.view.safeAreaInsets else { return }
self.update(safeAreaInsets: self.view.safeAreaInsets)
}
} else {
// KVOs for topLayoutGuide & bottomLayoutGuide are not effective.
Expand Down

0 comments on commit 80ec646

Please sign in to comment.