             if let frame = notification.userInfo?[UIKeyboardFrameEndUserInfoKey]?.CGRectValue() {
                 let rect = window.convertRect(frame, toView: view)
                 
-                keyboardHeight = view.bounds.size.height - rect.origin.y
-            }
-        }
-    }
-    
-    func keyboardDidShow(notification: NSNotification) {
-        backgroundViewBottomSpaceConstraint.constant = keyboardHeight
+                backgroundViewBottomSpaceConstraint.constant = view.bounds.size.height - rect.origin.y
+            }
+        }
     }
 }
 

        modalTransitionStyle = .CrossDissolve
        transitioningDelegate = self
        
        let center = NSNotificationCenter.defaultCenter()
        center.addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
        center.addObserver(self, selector: "keyboardDidShow:", name: UIKeyboardDidShowNotification, object: nil)
    }
    
    public override func viewDidLoad() {

            buttonViewHeightConstraint.constant = buttonView.contentSize.height
        }
        
        let backgroundViewHeight = view.bounds.size.height - backgroundViewBottomSpaceConstraint.constant
        if buttonViewHeightConstraint.constant > backgroundViewHeight {
            buttonView.contentSize.height = buttonViewHeightConstraint.constant
            buttonViewHeightConstraint.constant = backgroundViewHeight
