         notificationCenter.removeObserver(self)
     }
     
-    /**
-     *  临时启用或关闭管理器
-     */
-    var enabled = true
-    
-    /**
-     *  是否与键盘同时执行调整动画，默认为 YES。设置为 NO 后，将会在键盘显示之后再执行动画。
-     */
-    var animateAlongwithKeyboard = true
-    
     fileprivate let notificationCenter = NotificationCenter.default
-
     
     // MARK: - Private Logics
     fileprivate func registerKeyboardEvents()
     {
-        notificationCenter.addObserver(self, selector: .keyboardWillShow, name: Notification.Name.UIKeyboardWillShow, object: nil)
-        notificationCenter.addObserver(self, selector: .keyboardDidShow, name: Notification.Name.UIKeyboardDidShow, object: nil)
-        notificationCenter.addObserver(self, selector: .keyboardWillHide, name: Notification.Name.UIKeyboardWillHide, object: nil)
+        notificationCenter.addObserver(self, selector: #selector(keyboardWillShow), name: Notification.Name.UIKeyboardWillShow, object: nil)
+        notificationCenter.addObserver(self, selector: #selector(keyboardWillHide), name: Notification.Name.UIKeyboardWillHide, object: nil)
+        notificationCenter.addObserver(self, selector: #selector(keyboardDidShow), name: Notification.Name.UIKeyboardDidShow, object: nil)
+        notificationCenter.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: Notification.Name.UIKeyboardWillChangeFrame, object: nil)
     }
     
     fileprivate func viewBottomSpace() -> CGFloat
     {
         var bottomOffSet:CGFloat = 0
-        
         if let scrollView = self.viewToAdjust as? UIScrollView {
             bottomOffSet = scrollView.contentInset.bottom
             bottomOffSet = max(0, bottomOffSet)
         }
-        
         return self.viewController.view.frame.size.height - self.viewToAdjust.frame.size.height - self.viewToAdjust.frame.origin.y + bottomOffSet;
     }
 
     
     @objc internal func keyboardWillShow(_ notification:Notification) {
+        guard keyboardStatus == .hidden else {
+            return
+        }
+        
         self.originalBottomSpace = viewBottomSpace();
-        
         if (self.animateAlongwithKeyboard) {
             updateForKeyboard(withNotification: notification)
         }
-        notificationCenter.removeObserver(self, name: Notification.Name.UIKeyboardWillShow, object: self)
+        keyboardStatus = .showing
     }
+    
     @objc internal func keyboardDidShow(_ notification:Notification) {
+        guard keyboardStatus == .showing else {
+            return
+        }
+
         updateForKeyboard(withNotification: notification)
-        notificationCenter.addObserver(self, selector: .keyboardWillChangeFrame, name: Notification.Name.UIKeyboardWillChangeFrame, object: nil)
+        keyboardStatus = .shown
     }
+    
     @objc internal func keyboardWillChangeFrame(_ notification:Notification) {
+        
+        guard keyboardStatus != .hidden else {
+            return
+        }
+        
         updateForKeyboard(withNotification: notification)
     }
+    
     @objc internal func keyboardWillHide(_ notification:Notification) {
+        guard keyboardStatus != .hidden else {
+            return
+        }
         if (enabled) {
             let userInfo = notification.userInfo!
             let timeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue

    fileprivate var originalConstant:CGFloat
    fileprivate var originalBottomSpace:CGFloat = 0
    fileprivate var currentKeyboardHeight:CGFloat = 0
    /**
     *  创建键盘管理器
     *
     *  @param viewController 管理器所属的视图控制器
     *  @param constraint     关联的位置约束
     *  @param view           关联的底部的 View
     */
    init(withViewController viewController:UIViewController, positionConstraint:NSLayoutConstraint, viewToAdjust:UIView) {
        self.viewController = viewController
        self.viewToAdjust = viewToAdjust

    ///   - viewToAdjust: 键盘变化时需要调整的视图
    open func setupKeyboardManager(withPositionConstraint constraint:NSLayoutConstraint, viewToAdjust:UIView) {
        let manager = KeyboardManager(withViewController: self, positionConstraint: constraint, viewToAdjust: viewToAdjust)
        self.keyboardManager = manager;
    }
    
    fileprivate struct AssociatedKeys {
        static var KeyboardManagerKey = "KeyboardManagerKey"
    }
    
    /// 键盘管理器
    open var keyboardManager: KeyboardManager? {
        get {
            return objc_getAssociatedObject(self, &AssociatedKeys.KeyboardManagerKey) as? KeyboardManager
        }
