iphone 6+ real device on landscape view is not working - ios

An user reported that the iOS app on an iPhone 6+, the landscape view is not working.
I don't have a real iPhone 6+ to test it, but on the simulator it works fine. Any thoughts?

The problem was that I was using some #define code asking if the device was iPhone6+, and the code wasn't working as expected. So I changed the code to be like this:
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_6_PLUS (IS_IPHONE && IS_OS_8_OR_LATER && SCREEN_MAX_LENGTH == 736.0)

Related

How to define a preprocessor macro that uses another as a conditional?

I have a game that uses some common macros to figure out what device the user is on:
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_4 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0f)
#define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f)
#define IS_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0f)
#define IS_IPHONE_6P (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0f)
It's an older game, and I just want to use a multiplier adjust some positioning. A macro would be ideal:
#ifdef IS_IPHONE_6
#define SIZEMOD 1.172f
#elif IS_IPHONE_6P
#define SIZEMOD 1.6875f
#else
#define SIZEMOD 1.0f
#endif
Unfortunately, this checks to see if the macro IS_IPHONE_6 is defined, which will always be true and therefore the wrong multiplier is used on other devices. How can I properly define SIZEMOD using a macro?
I hope I don't get downvoted to hell for this 🙃
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_4 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0f)
#define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f)
#define IS_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0f)
#define IS_IPHONE_6P (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0f)
#define (SIZEMOD IS_IPHONE_6 ? 1.172f : IS_IPHONE_6P ? 1.6875f : 1.0)
I much better way to do this is use proper functions. Here's something I use often, which works well and supports all know iOS models.
https://github.com/duhovny/DeviceHardware

Determine iOS Simulator selected device

Is there a way to programmatically determine which simulated device is being used in the iPhone sim? UIDevice just returns iPhone Simulator, whether I pick iPhone4, 5s, 6, iPad, etc.
For know the current device.
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)

iPad and IPhone screen size definition error. iPad displays iPhone parametrers

At first i was making app for iPad, but then decided to make it universal but after i define screen size, like this :
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
Now on iPad screen size shows up like it was for iPhone, every thing on screen are too small. Is that some kind of bug? or i did something wrong, how can i change it?
iPad display iPhone parameter , the reason is that app screen size becomes zoom to fit on iPad screen, but actually it capturing iPhone screen size only.
To resolve this you need to make your app as Universal. In Xcode->Target->General->Deployment Info->Device Select Universal.

Knowing if "Display Zoom" is on [duplicate]

This question already has answers here:
How can I detect whether a user has an iPhone 6 Plus in standard or zoomed mode?
(6 answers)
Closed 7 years ago.
Is there a way to know if a user is using the iPhone 6/iPhone 6 Plus "Display Zoom" feature?
I'm talking about this feature.
You can use [UIScreen mainScreen].nativeScale witch will gives you 2.6f if normal, and 2.8f if zoomed on iPhone 6 plus.
Here is the screen bounds for If screen zoom or not
<UIScreenMode: 0x17802f240; size = 1242.000000 x 2208.000000> // STANDARD
<UIScreenMode: 0x178226be0; size = 1125.000000 x 2001.000000> // ZOOMED
For Programatically check for that need to use below code.
#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)

How to detect iPhone 6 (6 plus) on simulator

I have found this nice defines:
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
But when I run iPhone 6 simulator or iPhone 6 plus simulator it every time work as iPhone 5.
I have checked the screen size:
(lldb) po [UIScreen mainScreen]
<UIScreen: 0x7ffb3a402930; bounds = {{0, 0}, {320, 568}}; mode = <UIScreenMode: 0x7ffb3a520a80; size = 640.000000 x 1136.000000>>
and seems everting is clear why it points me to iPhone 5 instead of iPhone 6 or iPhone 6 plus.
You have to add the appropriate launch images so the app device/simulator starts using the real size and not a zoomed or emulated size, until you add a launch image for Retina HD 5.5 and Retina HD 4.7 you won't be using the new sizes.
Click the small grey arrow on the Launch Images Source in your Project General Settings and add the appropriate launch images.

Resources