iPad frame width and height mixup in landscape

后端 未结 2 379
无人及你
无人及你 2021-02-03 11:08

I have done what this question said here: Landscape Mode ONLY for iPhone or iPad

but the view.frame.size.height is still 1024, which is the height when the device is in

2条回答
  •  长情又很酷
    2021-02-03 12:03

    + (int) currentWidth
    {
     UIScreen *screen = [UIScreen mainScreen];
     int width = screen.currentMode.size.width;
     int height = screen.currentMode.size.height;
     return (UIDeviceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))? MAX (width, height) : MIN (width, height);
    }
    

    I spent a while trying to work out the simplest solution to a frustrating problem, and this was the best I could come up with. Hope it can help.

提交回复
热议问题