Skip to content

Commit 005dc32

Browse files
committed
fix invalid safearea insets in a table view with static cells
See also #330
1 parent 5787a35 commit 005dc32

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Framework/Sources/FloatingPanelController.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,10 @@ open class FloatingPanelController: UIViewController {
422422
// 2. The safe area top inset can be variable on the large title navigation bar(iOS11+).
423423
// That's why it needs the observation to keep `adjustedContentInsets` correct.
424424
safeAreaInsetsObservation = self.view.observe(\.safeAreaInsets, options: [.initial, .new, .old]) { [weak self] (_, change) in
425-
guard change.oldValue != change.newValue, let newValue = change.newValue else { return }
426-
self?.update(safeAreaInsets: newValue)
425+
// Use `self.view.safeAreaInsets` becauese `change.newValue` can be nil in particular case when
426+
// is reported in https://github.com/SCENEE/FloatingPanel/issues/330
427+
guard let `self` = self, change.oldValue != self.view.safeAreaInsets else { return }
428+
self.update(safeAreaInsets: self.view.safeAreaInsets)
427429
}
428430
} else {
429431
// KVOs for topLayoutGuide & bottomLayoutGuide are not effective.

0 commit comments

Comments
 (0)