I trying to make universal app for all IOS devises except for iPhone below 4 and I have this macros that work for IOS 8:
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] nativeBounds ].size.height - ( double )1136 ) < DBL_EPSILON )
#define IS_IPHONE_6 ( fabs( ( double )[ [ UIScreen mainScreen ] nativeBounds ].size.height - ( double )1334 ) < DBL_EPSILON )
here is the code I am using:
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
SKSpriteNode *background;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
if (IS_IPHONE_6) {
background = [SKSpriteNode spriteNodeWithImageNamed:@"Background-667"];
}
else if (IS_IPHONE_5) {
background = [SKSpriteNode spriteNodeWithImageNamed:@"Background-568"];
}else{
background = [SKSpriteNode spriteNodeWithImageNamed:@"Background"];
}
}else{
background = [SKSpriteNode spriteNodeWithImageNamed:@"Background~iPad"];
}
background.anchorPoint = CGPointMake(0.5, 1);
background.position = CGPointMake(self.size.width/2, self.size.height);
[self addChild:background];
}
return self;
}
but these macros doesn't work for IOS 7 to detect optimized images. In this forum How to detect iPhone 5 (widescreen devices)? they say you need to put this code and it will work
#define IS_WIDESCREEN_IOS7 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_WIDESCREEN_IOS8 ( fabs( ( double )[ [ UIScreen mainScreen ] nativeBounds ].size.height - ( double )1136 ) < DBL_EPSILON )
#define IS_WIDESCREEN ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_WIDESCREEN_IOS8 : IS_WIDESCREEN_IOS7 )
but when I do the app crashes.
What do I need to add to make it work? I am a beginner developer and dont understand how this macros work.