UIKeyboardWillChangeFrame and iPhone X

Trying with the simulator is here, and it seems that the frame returned when listening to the changes using the UIKeyboardWillChangeFrame is incorrect for iPhone X. In particular, the frame seems to be slightly higher than what it actually (visible) is on the screen. I would say that the returned frame is about 20 points higher.

Did I forget something obvious?

Some data ...

iPhone X and iPhone 8 have the same width in the portrait, which makes it the same height in the landscape; 375 points. ( https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions )

  // iPhone X values: // keyboardChange, frame: (0.0, 375.0, 812.0, 171.0) // keyboardChange, frame: (0.0, 204.0, 812.0, 171.0) // iPhone 8 values: // keyboardChange, frame: (0.0, 375.0, 667.0, 162.0) (keyboard closed) // keyboardChange, frame: (0.0, 213.0, 667.0, 162.0) (keyboard opened) 

We see that the Y value, when the keyboard is open on the iPhone X, is less, which leads us to align any of our own user interface elements higher on the screen. Those. they will not fit perfectly with the keyboard. What is my current problem, and I believe that all other applications that will do this will also suffer from this problem.

+1
source share
1 answer

There was not enough information in my question to be able to directly attack the problem, I see now. As I wrote in my comment above, the problem was not a problem with the iPhone X as such, but if you want to place the user interface element on top of the keyboard using the frame that comes with the UIKeyboardWillChangeFrame notification, you should definitely limit it to the extreme bottom of the surveillance, not the bottom of the safe zone that happened in my storyboard when I added the safe support zone.

+1
source

Source: https://habr.com/ru/post/1270363/


All Articles