【问题标题】:Images doesn't show on iPad 2 simulator with iOS 9图像不显示在带有 iOS 9 的 iPad 2 模拟器上
【发布时间】:2015-09-30 08:26:16
【问题描述】:

在资产目录中,我为 iPhone 和 iPad 设备设置了一个名为“panda”的图像。 iPhone 有 3 张图片,iPad 有 2 张图片

当我在装有 iOS 8.4 的 iPad Air、iPad Air 2、iPad Retina、iPad 2 上运行该应用程序时,图像会在点击时显示,但在装有 iOS 9 的 iPad 2 上没有任何反应!

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
   /* Called when a touch begins */

    for touch in touches {
        let location = touch.locationInNode(self)

        let sprite = SKSpriteNode(imageNamed:"panda")
        print(sprite)
        sprite.position = location

        let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)

        sprite.runAction(SKAction.repeatActionForever(action))

        self.addChild(sprite)
    }
}

使用版本 7.0

这里是设置

// 编辑 1.0

显然这是一个错误,尚未修复

https://forums.developer.apple.com/thread/4268 https://forums.developer.apple.com/message/36854#36854

【问题讨论】:

    标签: xcode ios9 asset-catalog


    【解决方案1】:

    尝试(目标-C)

    UIImage *img = [UIImage imageNamed:@"image"];
    SKTexture *textureBg = [SKTexture textureWithImage:img];
    SKSpriteNode *nodeBg = [SKSpriteNode spriteNodeWithTexture:textureBg];
    

    【讨论】:

    • 是的,这有效,而不是 SKSpriteNode(imageNamed:"panda")。 imageNamed 不起作用的任何原因?
    猜你喜欢
    • 2011-06-01
    • 2015-03-01
    • 1970-01-01
    • 2018-08-17
    • 2014-07-10
    • 2013-08-23
    • 2012-06-28
    • 2021-02-05
    • 1970-01-01
    相关资源
    最近更新 更多