【问题标题】:iOS spriteNode background image differences between ios 7 and ios 8ios 7 和 ios 8 的 iOS spriteNode 背景图区别
【发布时间】:2015-01-02 16:31:26
【问题描述】:

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

这是我正在使用的代码:

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

布局也有区别(我没用xibs),不过第一步是解决背景:)。

以下是 ios 7 % ios 8 的屏幕截图。

这是带有 images.xcassets 的屏幕截图:

谢谢,祝你有美好的一天,亚历克斯。

【问题讨论】:

  • 您能否更详细地解释一下图像显示不正确的原因?
  • 在 images.xcassets 我有 iphone @2x, 960x640 的图像,在 ios8 中一切似乎都正常,但在 ios 7 中图像更大
  • 您需要发布更多与您的 SKScene 设置相关的代码。屏幕截图会很有帮助。
  • 检查场景的 scaleMode,我相信默认可能已经改变,所以尝试明确设置它
  • 为 iPh5 添加启动图像:尺寸 640 x 1136 像素并命名为 Default-568h@2x.png

标签: ios ios7 ios8 sprite-kit skspritenode


【解决方案1】:

似乎 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 中搜索“orientation-dependency”来了解更多信息。希望这对您也有用。

【讨论】:

    猜你喜欢
    • 2014-11-17
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    • 2014-03-19
    • 2015-10-15
    • 1970-01-01
    相关资源
    最近更新 更多