iOS spriteNode ios 7和ios 8之间的背景图像差异

时间:2014-11-06 08:31:12

标签: ios ios7 ios8 sprite-kit skspritenode

我在iOS上面临这个问题(objective-c,而不是swift)。我从images.xcassets加载背景图像,它在iOS 8上正常显示,但在iOS 7上没有显示。有没有人遇到过这个问题?

这是我使用的代码:

    SKSpriteNode *background = [SKSpriteNode spriteNodeWithImageNamed:@"xxx"];
    background.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
    [self addChild:background];

布局也存在差异(我不使用xib),但第一步是解决背景问题:)。

以下是ios 7%ios 8的截图。 enter image description here enter image description here

以下是images.xcassets:

的屏幕截图

enter image description here 谢谢,祝你有个美好的一天,Alex。

1 个答案:

答案 0 :(得分:0)

似乎ios 7无法识别您的应用以横向模式启动,因此使用纵向尺寸初始化框架。我用以下方法解决了这个问题:

- (CGSize)screenSize {
    CGSize screenSize = [UIScreen mainScreen].bounds.size;
    if ((NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
        return CGSizeMake(screenSize.height, screenSize.width);
    }
    return screenSize;
}

您可以通过搜索“方向依赖”来了解更多信息。在iOS 8中。希望这对你也有用。