What is the height of iPad's onscreen keyboard?

前端 未结 12 2101
傲寒
傲寒 2020-12-08 03:45

I\'m looking for two numbers here: the height in portrait and the height in landscape. Don\'t answer in cm or inches, but rather in pixels.

12条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 04:22

    You can get the keyboard height from the userInfo dictionary returned by the will/did show/hide keyboard notification, as provided by the UIWindow class (reference guide link). This is a much better way of getting the height than hard-coding because you get the following benefits:

    • Device independence (iPhone/iPod or iPad)
    • Resolution independence (iPhone 3G screen/retina display/iPad display/future displays).
    • Keyboard type/style independence (different on-screen keyboards may have difference sizes).

    In fact, the answers to this question that give an exact number most likely got this number by looking at the results returned within this dictionary!

提交回复
热议问题