 
     func keyboardDidHide(notification: NSNotification) {
 
-        if UIApplication.sharedApplication().applicationState != .Active {
+        guard UIApplication.sharedApplication().applicationState != .Background else {
             return
         }
 

    
    func keyboardWillChangeFrame(notification: NSNotification) {

        if UIApplication.sharedApplication().applicationState != .Active {
            return
        }



    func keyboardWillShow(notification: NSNotification) {

        guard UIApplication.sharedApplication().applicationState != .Background else {
            return
        }

