How can I detect whether a user has an iPhone 6 Plus in standard or zoomed mode? How can I detect whether a user has an iPhone 6 Plus in standard or zoomed mode? ios ios

How can I detect whether a user has an iPhone 6 Plus in standard or zoomed mode?


There's a new member

[[UIScreen mainScreen] nativeScale]

which should do what you want. It's only available on iOS 8, so you'll need to guard it


[UIScreen mainScreen].currentMode reports:

<UIScreenMode: 0x17802f240; size = 1242.000000 x 2208.000000> // STANDARD<UIScreenMode: 0x178226be0; size = 1125.000000 x 2001.000000> // ZOOMED


The following code may be used to get bounds, coordinateSpace, nativeScale and scale, i.e. on an iPhone 6 Plus the nativeScale is 2.608 and when the device in run in Zoomed Mode it is 2.88 (note that it is different in the simulator):

UIScreen *mainScreen = [UIScreen mainScreen];NSLog(@"Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f",          NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace, mainScreen.scale, mainScreen.nativeScale);

Code for detecting iPhone 6 Plus:

-(BOOL)iPhone6PlusDevice{    // Scale is 3 currently only for iPhone 6 Plus    if ([UIScreen mainScreen].scale > 2.9) return YES;    return NO;}

or

 -(BOOL)iPhone6PlusUnZoomed{        if ([self iPhone6PlusDevice]){            if ([UIScreen mainScreen].bounds.size.height > 720.0) return YES;  // Height is 736, but 667 when zoomed.        }        return NO;    }

Note: If you are checking for iPhone 6 Plus, to adjust the user interface then donĀ“t rely on .nativeScale, because the simulator and an actual device give different results.


matomo