1

Trying with simulator here, and it seems that the frame returned when listening for changes with UIKeyboardWillChangeFrame is incorrect for iPhone X. Specifically the frame seems to be a bit taller than it actually is (visibly) on screen. I'd say the returned frame is about 20 points taller.

Did I forget something obvious?

Some data...

The iPhone X and iPhone 8 have the same width in portrait, which makes it the same height in 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 can see that the Y value when keyboard is opened on the iPhone X is smaller, which leads us to align any of our own UI elements higher on screen. Ie they will not align perfectly on top of the keyboard. Which is my current problem, and I assume all other apps doing that will also suffer from this problem.

Jonny
  • 15,955
  • 18
  • 111
  • 232
  • Related https://stackoverflow.com/questions/45399178/extend-ios-11-safe-area-to-include-the-keyboard – Jonny Oct 28 '17 at 00:18
  • FWIW, I need to check this with iOS 11.1 – Jonny Nov 02 '17 at 05:41
  • I found out the cause of my problem. I'm gonna close this. My problem was not related to iPhone X or anything per se. It was related to safe area, I had constrained my UI element to the bottom of the screen and that constraint ended up being attached to the bottom safe area, connecting it to the extreme bottom of the super view fixed my issue. – Jonny Nov 02 '17 at 06:36

1 Answers1

1

My question did not contain enough info to be able to directly attack the problem, I see now. As I wrote in my comment above, the issue was not a problem with iPhone X per se but if you want to put a UI element on top of the keyboard using the frame supplied with the UIKeyboardWillChangeFrame notification, you must make sure to constrain to the extreme bottom of the superview, and not to the safe area bottom, which had happened in my storyboard as I added safe area support.

Jonny
  • 15,955
  • 18
  • 111
  • 232