ios - UINavigationController in UITabBarController has a gap between the bottom of the view and keyboard -
i have uitabbarcontroller
has uinavigationcontrollers
it's tabs.
when keyboard opens up, there strange gap between bottom of view , keyboard. checked constraints , fine.
i have different viewcontroller has uitextview
, doesn't show gap between it.
here code adds keyboard height bottom constraint scrolls correctly , nothing gets hidden:
func setupkeyboardobserver() { nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("keyboardwasshown:"), name:uikeyboardwillshownotification, object: nil) nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("keyboardwillhide:"), name:uikeyboardwillhidenotification, object: nil) } func keyboardwasshown(notification: nsnotification) { let info = notification.userinfo! let keyboardframe: cgrect = (info[uikeyboardframeenduserinfokey] as! nsvalue).cgrectvalue() uiview.animatewithduration(0.1, animations: { () -> void in self.bottomconstraint.constant = keyboardframe.size.height }) } func keyboardwillhide(notification: nsnotification) { var info = notification.userinfo! var keyboardframe: cgrect = (info[uikeyboardframeenduserinfokey] as! nsvalue).cgrectvalue() uiview.animatewithduration(0.1, animations: { () -> void in self.bottomconstraint.constant = 0 }) }
Comments
Post a Comment