         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?

    func selectSecureQuestion(button: UIButton) {
        DDLogDebug("debug secure question")
        self.view.endEditing(true)
        // TODO: Make action sheet picker a view controller to avoid keyboard overlay.
        let picker = ActionSheetStringPicker(title: "安全提问", rows: secureQuestionChoices, initialSelection: currentSecureQuestionNumber(), doneBlock: { (pciker, selectedIndex, selectedValue) in
                button.setTitle(selectedValue as? String ?? "??", forState: .Normal)
                if selectedIndex == 0 {
