UI is messed up on iPad

My app supports only iPhone mode, and when it runs on an iPad device, it normally displays compatible iPhone mode;

But when compatibility mode is displayed normally, everything is fine in the UI.

But my code as long as you use the AVPictureInPictureController, open the picture in picture, can lead to code for [UIScreen mainScreen] bounds will change, become the real width and height of the equipment, so the UI disorder;

Problems arise when our code is laid out with [UIScreen mainScreen] bounds.

Like this:

This was normal in iOS16 and iOS17, but suddenly it happened in iOS18

How should my application be compatible with this?

The best thing to do for long term compatibility is to move away from using UIScreen whenever possible. In general you should do your layout work relative to some specific superview, and either inside a layoutSubviews method (UIViewController has 2 related methods) or via auto layout.

As for why this might be happening, it sounds like this is just a bug. But the only reasonable workaround I can imagine would still involve changing every location where your accessing UIScreen and which may create additional bugs along the way that may be easier to resolve with the better long term approach above.

UI is messed up on iPad
 
 
Q