ios - How can I make a textView sit on top of the keyboard when pressed? -


i have text view on bottom of 1 of views, , hidden keyboard when pops if didn't anything. did when keyboard appear, text view moves 160 points. problem doesn't sit in exact same place on every iphone because of different sizes. know if possible text view sit say, 20 points on top of keyboard, instead of pushing 160 points its' origin.

override func viewdidload() {     super.viewdidload()      nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("keyboardwillshow:"), name:uikeyboardwillshownotification, object: nil);     nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("keyboardwillhide:"), name:uikeyboardwillhidenotification, object: nil);  }  var isshown: bool = false var willhide: bool = false  func keyboardwillshow(sender: nsnotification) {      isshown = true  }  func keyboardwillhide(sender: nsnotification) {      willhide = true  }  func textviewdidbeginediting(textview: uitextview) {     if isshown == true {          self.view.frame.origin.y -= 160      } }  func textviewdidendediting(textview: uitextview) {     if willhide == true {          self.view.frame.origin.y += 160      } } 

you can size of keyboard notification object.

something

nsdictionary* info = [sender userinfo]; cgsize kbsize = [[info objectforkey:uikeyboardframebeginuserinfokey] cgrectvalue].size; 

you can read more here in apple docs


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -