Skip to content

Commit

Permalink
Fix #299
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamazz committed Mar 16, 2018
1 parent 4801251 commit c382e61
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Source/ScrollingNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ open class ScrollingNavigationController: UINavigationController, UIGestureRecog

open fileprivate(set) var gestureRecognizer: UIPanGestureRecognizer?
fileprivate var sourceTabBar: TabBarMock?
fileprivate var previousOrientation: UIDeviceOrientation = UIDevice.current.orientation
var delayDistance: CGFloat = 0
var maxDelay: CGFloat = 0
var scrollableView: UIView?
Expand Down Expand Up @@ -134,6 +135,7 @@ open class ScrollingNavigationController: UINavigationController, UIGestureRecog
gestureRecognizer?.delegate = self
scrollableView.addGestureRecognizer(gestureRecognizer!)

previousOrientation = UIDevice.current.orientation
NotificationCenter.default.addObserver(self, selector: #selector(ScrollingNavigationController.willResignActive(_:)), name: NSNotification.Name.UIApplicationWillResignActive, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(ScrollingNavigationController.didBecomeActive(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(ScrollingNavigationController.didRotate(_:)), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
Expand Down Expand Up @@ -264,7 +266,11 @@ open class ScrollingNavigationController: UINavigationController, UIGestureRecog
// MARK: - Rotation handler

func didRotate(_ notification: Notification) {
showNavbar()
let newOrientation = UIDevice.current.orientation
if (previousOrientation.isPortrait && newOrientation.isLandscape) || (previousOrientation.isLandscape && newOrientation.isPortrait) {
showNavbar()
}
previousOrientation = newOrientation
}

/**
Expand Down

0 comments on commit c382e61

Please sign in to comment.