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

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -