How to determine if the iPhone 6+ (plus) is in Sta

2020-05-08 08:33发布

问题:

I'm trying to determine if the iPhone 6+ is in standard or zoom mode and I can't find any API's that help determine this, so far the only thing that is indicating which mode the phone is in is the nativeScale

if ([UIScreen mainScreen].nativeScale == 3.0) {
    // its in the simulator
} else if ([UIScreen mainScreen].nativeScale == 2.880000) {
    // its an iPhone 6+ in zoom mode
} else if ([UIScreen mainScreen].nativeScale == 2.6086956521739131) {
    // its an iPhone 6+ in standard mode
}

回答1:

How about just checking the bounds (not nativeBounds) of the screen? IIRC, in zoom mode the bounds will be {375, 667} but in regular mode they are {414, 736}.

But yes, as mentioned in the comments.. if you are using AutoLayout, your app should "just" be able to adjust itself correctly and you shouldn't need to know.



回答2:

//you can check it from here

CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
    NSLog(@"screnn width is ----<%f",screenWidth);



                       or


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


NSLog(@"screnn width is ----<%f",self.window.frame.size.width);
NSLog(@"screnn width is ----<%f",[[UIScreen mainScreen] bounds].size.height);


标签: ios iphone ios8