I am developing universal up, to be clear I want my iphone app that I have to be also for all devices so I have problem with it. I am using Xcode 6.1 All simulator For IOS 8 are working but Non Of IOS 7 simulators working, the app is crashing when I try to use any IOS 7 simulator. Here is my code in MyScene.m file under #import MyScene.h I put this code
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) // iPhone and iPod touch style UI
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) // iPhone and iPod touch style UI
#define IS_IPHONE_5_IOS7 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f)
#define IS_IPHONE_6_IOS7 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0f)
#define IS_IPHONE_6P_IOS7 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0f)
#define IS_IPHONE_4_AND_OLDER_IOS7 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height < 568.0f)
#define IS_IPHONE_5_IOS8 (IS_IPHONE && ([[UIScreen mainScreen] nativeBounds].size.height/[[UIScreen mainScreen] nativeScale]) == 568.0f)
#define IS_IPHONE_6_IOS8 (IS_IPHONE && ([[UIScreen mainScreen] nativeBounds].size.height/[[UIScreen mainScreen] nativeScale]) == 667.0f)
#define IS_IPHONE_6P_IOS8 (IS_IPHONE && ([[UIScreen mainScreen] nativeBounds].size.height/[[UIScreen mainScreen] nativeScale]) == 736.0f)
#define IS_IPHONE_4_AND_OLDER_IOS8 (IS_IPHONE && ([[UIScreen mainScreen] nativeBounds].size.height/[[UIScreen mainScreen] nativeScale]) < 568.0f)
#define IS_IPHONE_5 ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_IPHONE_5_IOS8 : IS_IPHONE_5_IOS7 )
#define IS_IPHONE_6 ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_IPHONE_6_IOS8 : IS_IPHONE_6_IOS7 )
#define IS_IPHONE_6P ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_IPHONE_6P_IOS8 : IS_IPHONE_6P_IOS7 )
#define IS_IPHONE_4_AND_OLDER ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_IPHONE_4_AND_OLDER_IOS8 : IS_IPHONE_4_AND_OLDER_IOS7 )
In my MyScene.m file I use method to add sprite to the scene and I want when I build and run specific simulator let say iPone 6 optimizes image would apear here is the code:
- (void)setupBackground
{
UIScreen *mainScreen = [UIScreen mainScreen];
NSLog(@"Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f",
NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace, mainScreen.scale, mainScreen.nativeScale);
SKSpriteNode *background = [SKSpriteNode spriteNodeWithImageNamed:@"Background"];
if (IS_IPHONE_5)
{
background = [SKSpriteNode spriteNodeWithImageNamed:@"Background-568@2x.png"];
}
else if (IS_IPHONE_6_IOS8)
{
background = [SKSpriteNode spriteNodeWithImageNamed:@"Background-667@2x.png"];
}
else if (IS_IPHONE_6P_IOS8)
{
background = [SKSpriteNode spriteNodeWithImageNamed:@"Background@3x.png"];
}
but when I run it in IOS simulator the app crashes and in debug area show this message
2014-12-01 09:17:59.834 FlappyGame[2900:60b] -[UIScreen coordinateSpace]: unrecognized selector sent to instance 0x7fb211603700 2014-12-01 09:17:59.841 FlappyGame[2900:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIScreen coordinateSpace]: unrecognized selector sent to instance
Please help me solve this problem. What did I do wrong here?
Aucun commentaire:
Enregistrer un commentaire