0

在 iOS 8 中,UIScreen 类的所有权边界现在反映了设备的方向。为了解决这个问题,我可以使用属性的新 nativeBounds,而不是边界。nativeBounds 以像素为单位。那么我为......区域中的像素放置了什么代码?(此代码在我的 AppDelegate.m 中)

     [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ];

  if (................... == 1334) { 

        UIStoryboard *iPhone6 = [UIStoryboard storyboardWithName:@"iPhone6" bundle:nil];

        UIViewController *initialViewController =[iPhone6 instantiateInitialViewController];

        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];

        self.window.rootViewController = initialViewController;

        [self.window makeKeyAndVisible];
   }

或者我是否为 nativeBounds 实现了错误的整个代码?

屏幕边界不起作用...

    CGRect screenBounds=[[UIScreen mainScreen] bounds];

    if (screenBounds.size.height == 667) {  //code }
4

1 回答 1

0

您可以使用屏幕边界:

let screenBounds: CGRect = UIScreen.mainScreen().bounds

//additionally you can use these two lines to make upcoming code shorter
let screenWidth = screenSize.width
let screenHeight = screenSize.height

if (screenHeight == 1334) {
    //code goes here
}
于 2015-03-17T18:24:11.057 回答