- List Contents
Monitor keyboard up and down there are four states that can be heard.
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) { //Get keyboard information let keyboardinfo = notification.userinfo![ Uikeyboardframebeginuserinfokey] Let keyboardheight:cgfloat = (keyboardinfo?. CGRectValue.size.height)! Print ("keyboard bouncing") print (keyboardheight) } func keyboardwilldisappear (notification:nsnotification) { Print ("Keyboard Falls") }
Swift Gets the keyboard height