Search code examples
iosobjective-cuikitios16

Objective C App has wrong [UIScreen mainScreen].bounds value since iOS 16


Device: Physical iPhone X (16.0.2)

A legacy app (Objective C) of my client has worked just fine on iOS 15. On iOS 16 though, the app has suddenly 'shrunken in height'. The app opens as usual but on the top and bottom of the screen, there are black bars, as the app itself seems to be constrained to a certain size.

After some investigation, I found out that the device actually reports its Screen Height to be 480pt (iPhone X). Forcing the UIWindow to have a different size doesn't solve the issue, the app is still constrained to be the same wrong height. It seems the device 'actually believes' to be shorter than it is.

Since this behavior kind of resembles what happens when starting an iPhone app on an iPad (at least I remember seeing something like that some time ago), I was wondering whether or not this behavior is expected as of iOS 16?

If not, I would really appreciate some help here.

EDIT: I learned that +[UIScreen mainScreen] is deprecated as of iOS 16 so using that to initialize the window might be the issue. Though there seems to be no alternative for accessing this info all the way back in the AppDelegate. It was suggested to use self.view.window.windowScene.screen for reading a device's screen size, but sadly this is not accessible in the AppDelegate.


Solution

  • WORKAROUND:

    I was not able to find the root cause of the issue but could resolve it by using storyboards to load the initial ViewController. This caused the system to automatically create a window, which was not affected by this weird system behavior.