IOS 9 / Xcode 7: SKSpriteNode spriteNodeWithImageNamed not working on some devices

I'm having problems loading an image from the .xcassets image set for SKSpriteNode.

While it worked perfectly on iOS 8.x using [SKSpriteNode spriteNodeWithImageNamde: imageName], it doesn’t work on some devices on iOS 9. For example, it works on the iPhone 6/6 Plus and iPad Air, but not on iPod Touch 5G.

Works on all devices with iOS 8.x, but not on all devices (e.g. iPod Touch 5g) on ​​iOS 9.x (Xcode 7, Xcode 7.1 Beta 3):

SKSpriteNode *background = [SKSpriteNode spriteNodeWithImageNamed:@"MenuBackgroundImage"]; background.anchorPoint = CGPointMake(0, 0); background.zPosition = 100; [self addChild:background]; 

Interestingly, it works on iOS 9 if I upload an image as follows:

 SKTexture *imageTexture = [SKTexture textureWithImage:[UIImage imageNamed:@"MenuBackgroundImage"]]; SKSpriteNode* background = [SKSpriteNode spriteNodeWithTexture:imageTexture]; 

The problem is that if I load an image from UIImage, internal caching will not work. Does anyone know how to properly load ImageSet from .xcassets in iOS 9 so that it works on ALL devices?

+5
source share

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


All Articles