监听键盘高度变化

keyboard 监听 改变高度

倖福魔咒の 提交于 2020-03-06 10:36:27
Swift: 1.注册通知 监听 NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardChangeFrame:", name: UIKeyboardDidChangeFrameNotification, object: nil); NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil); NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHidden:", name: UIKeyboardWillHideNotification, object: nil) 2.实现三个方法,change如果是数字键盘,用不到可为里面不写东西 func keyboardWillShow(aNotification:NSNotification){ keyboardStatus = KeyBoardStatus.toShow let moveFrame = CGRectMake(0,