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
Post a Comment