How to detect iPhone 6 & 6 Plus View Mode Programmatically [duplicate]

放肆的年华 提交于 2019-12-30 06:03:25

问题


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.



来源:https://stackoverflow.com/questions/30275403/how-to-detect-iphone-6-6-plus-view-mode-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!