Spritekit/Universal images from assets not showing

2019-07-10 04:37发布

问题:

I made a universal app using SpriteKit and Swift. Users have sent out bug reports on iOS 9 where sprite node images are showing up white/blank. But I haven't been able to reproduce this in the simulator. The images that don't show up are all device-specific in images.xcassets.

The images that do show up are the ones that are universal in images.xcassets.

What could I do to solve this (besides making them not device-specific) and could this possibly be an XCode/iOS bug?

回答1:

Yeah it's a bug for iOS 9.

What has worked so far is rebuilding everything and adding the format extension of the image whenever you call it. So for example, if your image is .png, then when you say something like:

SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"myImage.png"];

Try this instead of using the string "myImage", which would normally work for previous OS's.



回答2:

Please make sure that image adding into the images.xcassets is into png. if you used Jpg / jpeg then some time its not working into Xcode 7 / iOS 9.0