How to detect iPhone 6 & 6 Plus View Mode Programm

2019-02-12 14:28发布

问题:

This question already has an answer here:

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

Is there any way to identify View Mode( In setting > Display & Brightness ) programmatically ?

Many apps design are behaving differently in Standard Mode and Zoomed Mode.

Please refer image :

Any Help would be appreciated. :)

回答1:

You can use either [UIScreen mainScreen].nativeScale witch will gives you 2.6f if normal, and 2.8f if zoomed on iPhone 6 plus, or the defined macros :

#define IS_OS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 (IS_IPHONE && ([[UIScreen mainScreen] bounds].size.height == 568.0) && ((IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale) || !IS_OS_8_OR_LATER))
#define IS_STANDARD_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0  && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale)
#define IS_ZOOMED_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale > [UIScreen mainScreen].scale)
#define IS_STANDARD_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_ZOOMED_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale < [UIScreen mainScreen].scale)


回答2:

I was facing same issue when I install Application in 2 types of devices iPhone 6 (Standard mode) and iPhone 6 (Zoom mode) but later on I try to catch the height and width of the iPhone when it launch.

in your ViewController.h class in viewDidLoadmethod try to check the height and width in console.

NSLog(@"width %f, height %f",self.view.frame.size.width,self.view.frame.size.height);

By checking this you can get difference between Standard and Zoom mode.

From the Vizllx answer u can also check like below what I tried.

UIScreen *MainScreen = [UIScreen mainScreen];
UIScreenMode *ScreenMode = [MainScreen currentMode];
CGSize Size = [ScreenMode size];
NSLog(@"width %f, height %f",Size.width,Size.height);

Thanks.