第三方搜狗键盘keyboardwillshow通知走三次解决方案
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification , object: nil) func keyboardWillShow(notification:NSNotification){ let keyboardInfo = notification.userInfo![UIKeyboardFrameEndUserInfoKey] let keyboardHeight:CGFloat = (keyboardInfo?.CGRectValue.size.height)! if keyboardHeight != 0{ UIView.animateWithDuration(1.0) { if UIScreen.mainScreen().bounds.height-self.loginButton.frame.origin.y-keyboardHeight < 0 { self.view.frame = CGRectMake(0, (UIScreen.mainScreen().bounds.height-self.loginButton.frame.origin.y-keyboardHeight), self.view.frame.size.width, self.view.frame.size.height) }else { self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) } } } }