Reporting incorrect bounds in landscape Mode

前端 未结 9 1132
青春惊慌失措
青春惊慌失措 2020-12-05 02:57

I am having an issue with Landscape mode in my iPad application.

I created a very small new project to show my issue I set UIInterfaceOrientation in the pList to UII

9条回答
  •  生来不讨喜
    2020-12-05 03:30

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    CGRect r = self.view.frame;
    CGFloat width = r.size.width;
    CGFloat height = r.size.height;
    r.size.height = (UIInterfaceOrientationIsLandscape(orientation)) ? MIN(width, height): MAX(width, height);
    r.size.width  = (UIInterfaceOrientationIsLandscape(orientation)) ? MAX(width, height): MIN(width, height);
    self.view.frame = r;
    

提交回复
热议问题