         didSet {
             oldValue?.removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
             oldValue?.removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
+            oldValue?.removeObserver(self, name: UIKeyboardDidHideNotification, object: nil)
 
             keyboardChangeObserver?.addObserver(self, selector: "handleKeyboardWillShowNotification:", name: UIKeyboardWillShowNotification, object: nil)
             keyboardChangeObserver?.addObserver(self, selector: "handleKeyboardWillHideNotification:", name: UIKeyboardWillHideNotification, object: nil)
+            keyboardChangeObserver?.addObserver(self, selector: "handleKeyboardDidHideNotification:", name: UIKeyboardDidHideNotification, object: nil)
         }
     }
 

            let keyboardEndFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
            let keyboardHeight = keyboardEndFrame.height

            UIView.animateWithDuration(animationDuration, delay: 0, options: UIViewAnimationOptions(animationCurveValue << 16), animations: { () -> Void in
                self.messageToolbarBottomConstraint.constant = keyboardHeight
                self.view.layoutIfNeeded()

                self.conversationCollectionView.contentOffset.y += keyboardHeight
                self.conversationCollectionView.contentInset.bottom += keyboardHeight

            }, completion: { (finished) -> Void in
            })
        }
    }

    func handleKeyboardWillHideNotification(notification: NSNotification) {
        println("hideKeyboard")

        if let userInfo = notification.userInfo {
            let animationDuration: NSTimeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue

    var lastTimeMessagesCount: UInt = 0

    var conversationCollectionViewHasBeenMovedToBottomOnce = false


    // Keyboard 动画相关
    var conversationCollectionViewContentOffsetBeforeKeyboardWillShow = CGPointZero
    var conversationCollectionViewContentOffsetBeforeKeyboardWillHide = CGPointZero
    //var messageToolbarBottomConstraintConstantAfterKeyboardWillShow: CGFloat = 0
    var isKeyboardVisible = false
    var keyboardHeight: CGFloat = 0
    //var firstTime = true

    var keyboardShowTimes = 0 {
        willSet {
            println("set keyboardShowTimes \(newValue)")

            if newValue == 0 {
                if !self.isKeyboardVisible {
                    var contentOffset = self.conversationCollectionViewContentOffsetBeforeKeyboardWillShow
                    contentOffset.y += keyboardHeight
                    self.conversationCollectionView.setContentOffset(contentOffset, animated: true)

                    println("fire setContentOffset")

                    self.isKeyboardVisible = true

                } else {
//                    var contentOffset = conversationCollectionView.contentOffset//self.conversationCollectionViewContentOffsetBeforeKeyboardWillShow
//
//                    let dy = /*keyboardHeight*/self.messageToolbarBottomConstraint.constant - (messageToolbarBottomConstraintConstantAfterKeyboardWillShow /*+ self.messageToolbar.intrinsicContentSize().height*/)//self.messageToolbarBottomConstraint.constant
//                    contentOffset.y += dy
//                    println("XXXcontentOffset.y += \(self.messageToolbarBottomConstraint.constant) - \(messageToolbarBottomConstraintConstantAfterKeyboardWillShow)")
//                    self.conversationCollectionView.setContentOffset(contentOffset, animated: true)
//
//                    firstTime = true
                }
            }
        }
    }


    @IBOutlet weak var conversationCollectionView: UICollectionView!

