ios - keyboard is shown and the predictive text box on the top of the keyboard is toggled the view shoots up leaving a user with a black screen -


i have bug when keyboard shown , predictive text box on top of keyboard toggled view shoots leaving user black screen. reason happens because i'm using -= operator, compounds value every time method called. method can called multiple times in row. i'm trying find way handle this.

func getkeyboardheight(notification: nsnotification) -> cgfloat {      let userinfo = notification.userinfo     let keyboardsize = userinfo![uikeyboardframeenduserinfokey] as! nsvalue     return keyboardsize.cgrectvalue().height  }  func keyboardwillshow(notification: nsnotification) {      if bottomtextfield.isfirstresponder() {         self.view.frame.origin.y -= getkeyboardheight(notification)     }  }  func keyboardwillhide(notification: nsnotification) {      if bottomtextfield.isfirstresponder() {         self.view.frame.origin.y += getkeyboardheight(notification)     }  } 

by switching self.view.frame.origin.y -= getkeyboardheight(notification) view.frame.origin.y = -getkeyboardheight(notification) solved issue.

func keyboardwillshow(notification: nsnotification) {      if bottomtextfield.isfirstresponder() {         self.view.frame.origin.y = -getkeyboardheight(notification)     }  } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -