How to detect the host application in zoom mode or in normal mode in iPhone 6 Plus?

Assuming the iPhone 6 Plus display is in standard mode (Settings> View> View> Standard), the UIInputViewController inputView the keyboard extension with different widths depends on whether the host application is optimized for iPhone 6 / iPhone 6 Plus.

For example, the built-in Notes application returns a width of 414 points (no increase), where the LINE application (v.7.7.2 version) returns 320 points (increased).

How does the keyboard extension determine the width of the host application window (say, in viewDidLoad , to viewDidiLoad )?

+5
source share
1 answer

You can use certain 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) 

Or [UIScreen mainScreen].nativeScale witch will give you 2.6f if normal, and 2.8f if enlarged on iPhone 6 plus

0
source

Source: https://habr.com/ru/post/1207386/


All Articles