ios - Can't dismiss keyboard for iPhone 5 and iPhone5s -


i'm trying dismiss on screen keyboard programmatically , have code below

override func viewdidload() {     nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("keyboardwillshow:"), name:uikeyboardwillshownotification, object: nil);     nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("keyboardwillhide:"), name:uikeyboardwillhidenotification, object: nil); }  func keyboardwillshow(notification: nsnotification) {     var info = notification.userinfo!     let keyboardframe: cgrect = (info[uikeyboardframeenduserinfokey] as! nsvalue).cgrectvalue()     uiview.animatewithduration(0.1, animations: { () -> void in         self.bottomspace.constant = keyboardframe.size.height     }) }  func keyboardwillhide(notification: nsnotification){     self.bottomspace.constant = 0 } 

it work fine iphone 6 , ipad, not iphone 5 , iphone 5s, suggestion?

try this:

 // dismiss keyboard when user touch screen     override func touchesbegan(touches: set<uitouch>, withevent event: uievent?) {         self.view.endediting(true)     } 

let me know if works!


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -