Skip to content

Commit

Permalink
Remove Gesture when deinit
Browse files Browse the repository at this point in the history
  • Loading branch information
ANNotunzdY committed Mar 22, 2017
1 parent 4e4aa98 commit c0d38c5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions HidingNavigationBar/HidingNavigationBarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ open class HidingNavigationBarManager: NSObject, UIScrollViewDelegate, UIGesture
// Hiding navigation bar state
fileprivate var currentState = HidingNavigationBarState.Open
fileprivate var previousState = HidingNavigationBarState.Open

//Gesture
fileprivate var panGesture: UIPanGestureRecognizer?

//Options
open var onForegroundAction = HidingNavigationForegroundAction.default
Expand Down Expand Up @@ -87,6 +90,7 @@ open class HidingNavigationBarManager: NSObject, UIScrollViewDelegate, UIGesture
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(HidingNavigationBarManager.handlePanGesture(_:)))
panGesture.delegate = self
scrollView.addGestureRecognizer(panGesture)
self.panGesture = panGesture

navBarController.expandedCenter = {[weak self] (view: UIView) -> CGPoint in
return CGPoint(x: view.bounds.midX, y: view.bounds.midY + (self?.statusBarHeight() ?? 0))
Expand All @@ -106,6 +110,9 @@ open class HidingNavigationBarManager: NSObject, UIScrollViewDelegate, UIGesture

deinit {
NotificationCenter.default.removeObserver(self)
if let panGesture = panGesture {
scrollView.removeGestureRecognizer(panGesture)
}
}

//MARK: Public methods
Expand Down

0 comments on commit c0d38c5

Please sign in to comment.