 
         additionalSafeAreaInsets = searchResultsCollectionViewController.additionalSafeAreaInsets
         scrollView = searchResultsCollectionViewController.collectionView
+    }
+
+    override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
+        super.willTransition(to: newCollection, with: coordinator)
+        if isKeyboardShowing {
+            setUnderBarViewPercentHidden(navigationBar.underBarViewPercentHidden)
+        }
     }
 
     private var selectedImageViewHeightConstraint: NSLayoutConstraint?


    private var isKeyboardShowing = false

    private func setUnderBarViewPercentHidden(_ underBarViewPercentHidden: CGFloat, completion: @escaping () -> Void) {
        UIView.animate(withDuration: 0.3, animations: {
            self.navigationBar.setNavigationBarPercentHidden(0, underBarViewPercentHidden: underBarViewPercentHidden, extendedViewPercentHidden: 0, topSpacingPercentHidden: 0, animated: true) {
                self.useNavigationBarVisibleHeightForScrollViewInsets = true

        }, completion: { _ in
            self.useNavigationBarVisibleHeightForScrollViewInsets = false
            self.navigationBar.isUnderBarViewHidingEnabled = true
            completion?()
        })
    }
}
