监听键盘起落 下面是可以监听到得四种状态
UIKeyboarDWillShowNotification: String
UIKeyboardDIDShowNotification: String
UIKeyboarDWillHIDeNotification: String
UIKeyboardDIDHIDeNotification: String
NSNotificationCenter.defaultCenter().addobserver(self,selector: "keyboarDWillAppear:",name: UIKeyboarDWillShowNotification,object: nil)NSNotificationCenter.defaultCenter().addobserver(self,selector: "keyboarDWilldisappear:",name:UIKeyboarDWillHIDeNotification,object: nil)
func keyboarDWillAppear(notification: NSNotification) { // 获取键盘信息 let keyboardinfo = notification.userInfo![UIKeyboardFrameBeginUserInfoKey] let keyboardheight:CGfloat = (keyboardinfo?.CGRectValue.size.height)! print("键盘d起") print(keyboardheight) } func keyboarDWilldisappear(notification:NSNotification){ print("键盘落下") }总结
以上是内存溢出为你收集整理的swift2.0 动态获取键盘高度 Get KeyboardHeight全部内容,希望文章能够帮你解决swift2.0 动态获取键盘高度 Get KeyboardHeight所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)