1

I want to set a view frame to be above the keyboard. That it will not need to change height/location after keyboard appears.

Is there a way to get keyboard height in ViewDidLoad and not after keyboard appears?

Thanks


with and without keyboard the view should always be in the same place.

image

ilan
  • 4,402
  • 6
  • 40
  • 76
  • Check this : http://www.idev101.com/code/User_Interface/sizes.html – Kumar KL Jan 31 '17 at 08:41
  • what u r trying to do with this ? – Kumar KL Jan 31 '17 at 08:42
  • i added an image for explanation – ilan Jan 31 '17 at 08:48
  • if user is using a custom keyboard, you wont exactly know the height until the keyboard is about to be shown, [see this answer](http://stackoverflow.com/a/27798712/1219956) – Fonix Jan 31 '17 at 08:55
  • Event if the user is using a custom keyboard, IOS knows about it. – ilan Jan 31 '17 at 08:58
  • 1
    if u really want the UI should be that way . then u should hard code those heights based on devices . – Kumar KL Jan 31 '17 at 08:59
  • check out this http://arsenkin.com/how-to-get-ios-keyboard-height-programmatically.html – Gagan_iOS Jan 31 '17 at 09:02
  • The keyboard height depends on the model, the QuickType bar, user settings but fairly anyone can say that keyboard height is 216pts for portrait and 162pts for Landscape. Again it must be a good idea if you calculate it dynamically. – onCompletion Jan 31 '17 at 09:02
  • @Gagan_iOS this is with notifications, a not what i need, thanks anyway. – ilan Jan 31 '17 at 09:04

1 Answers1

1

There are fixed sizes for Keyboard heights in iOS.

Here's some documentation that would help you. http://www.idev101.com/code/User_Interface/sizes.html

You can just check what device is being using and find its keyboard height accordingly.

Clinton D'Souza
  • 301
  • 2
  • 8