I have iOS app and I´m using the size directives explained at this post.
I'm testing using iOS simulator on the latest Xcode (6.4) version. When I run my project, and select iPhone 4s on the device selection, the project runs with the correct detection message and the correct Storyboard; The same if I run using iPhone 5 and iPhone 5s. But when I select the iPhone 6 or 6 Plus, the detection and the console log that i have put at this part detects the iPhone as Iphone 5 and shows the storyboard for iPhone 5. I try to detect the resolution (in points of the CGRect height and show on the console log using NSLog, but no matters that the simulator display a window with te correct size, in the log appear the resolution size of an iphone 5.
There is the code when i define the directives:
#define IS_IPHONE_4 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)480) < DBL_EPSILON)
#define IS_IPHONE_5 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSILON)
#define IS_IPHONE_6 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)667) < DBL_EPSILON)
#define IS_IPHONE_6P (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)736) < DBL_EPSILON)
And there is the code when i detect the device:
//Para detectar screen size
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if (IS_IPHONE_4)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"4sStoryboard" bundle:[NSBundle mainBundle]];
UIViewController *vc =[storyboard instantiateInitialViewController];
self.window.rootViewController = vc;
NSLog(@"iPhone 4 storyboard loaded up.");
}
else
{
if(IS_IPHONE_5)
{
UIStoryboard *storyboard1 = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
UIViewController *vc2 =[storyboard1 instantiateInitialViewController];
self.window.rootViewController = vc2;
NSLog(@"iPhone 5 storyboard loaded up.");
}
else
{
if (IS_IPHONE_6)
{
UIStoryboard *storyboard1 = [UIStoryboard storyboardWithName:@"6Storyboard" bundle:[NSBundle mainBundle]];
UIViewController *vc2 =[storyboard1 instantiateInitialViewController];
self.window.rootViewController = vc2;
NSLog(@"iPhone 6 storyboard loaded up.");
}
else
{
if (IS_IPHONE_6P)
{
UIStoryboard *storyboard1 = [UIStoryboard storyboardWithName:@"6pStoryboard" bundle:[NSBundle mainBundle]];
UIViewController *vc2 =[storyboard1 instantiateInitialViewController];
self.window.rootViewController = vc2;
NSLog(@"iPhone 6 plus storyboard loaded up.");
}
}
}
And this is the exit of my log no matter if is iphone 5 or 6 or 6plus, The detection of iPhone 4s works normally:
2015-09-04 15:44:55.823 denuncia[1737:156925] iPhone 5 storyboard loaded up.
How I can ressolve this issue? I have working arrond this a long time and soon can have some troubles... I really appreciate your help.