         let dragGesture = UIPanGestureRecognizer(target: self, action: #selector(S1LoginViewController.pan(_:)))
         self.view.addGestureRecognizer(dragGesture)
         self.dragGesture = dragGesture
+
+        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(S1LoginViewController.keyboardFrameWillChange(_:)), name: UIKeyboardWillChangeFrameNotification, object: nil)
+    }
+
+    deinit {
+        NSNotificationCenter.defaultCenter().removeObserver(self)
     }
 
     override func viewDidLayoutSubviews() {

    let seccodeImageView = UIImageView(image: nil)
    let seccodeField = UITextField(frame: CGRect.zero)

    var dynamicAnimator: UIDynamicAnimator?
    var snapBehavior: UISnapBehavior?
    var dynamicItemBehavior: UIDynamicItemBehavior?

            presentingViewController.dismissViewControllerAnimated(true, completion: nil)
        } else {
            self.dismissViewControllerAnimated(true, completion: nil)
        }
    }

    func keyboardFrameWillChange(notification: NSNotification) {
        guard let userInfo = notification.userInfo, endFrame = userInfo[UIKeyboardFrameEndUserInfoKey]?.CGRectValue() else { return }

        let keyboardHeightInView = self.view.bounds.maxY - endFrame.minY
        DDLogDebug("[LoginVC] keytboard height: \(keyboardHeightInView)")
        visibleLayoutGuide.snp_updateConstraints { (make) in
            make.bottom.equalTo(self.view).offset(-keyboardHeightInView)
        }
    }
}
