【发布时间】:2017-06-02 10:42:49
【问题描述】:
我正在尝试在找到“条形码”时以编程方式更改场景,但我不断收到错误...
进口模块:
import UIKit
import AVFoundation
import SpriteKit
import SceneKit
代码:
if metadataObj.stringValue != nil {
messageLabel.text = "Found: " + metadataObj.stringValue
myBarcode = metadataObj.stringValue
let transition = SKTransition.reveal(with: .down, duration: 1.0)
let nextScene = WebLogger(size: scene!.size) *<-- use of unresolved identifier 'scene'
nextScene.scaleMode = .AspectFill
scene?.view?.presentScene(nextScene, transition: transition) *<-- use of unresolved identifier 'scene'
}
通过添加修复问题 1
var scene = SKScene()
问题 2 调用中的参数标签不正确(具有“大小:”,预期为“编码器:”)
var scene = SKScene()
if metadataObj.stringValue != nil {
messageLabel.text = "Found: " + metadataObj.stringValue
myBarcode = metadataObj.stringValue
let transition = SKTransition.reveal(with: .down, duration: 1.0)
let nextScene = WebLogger(size: scene!.size) *<-- Incorrect argument label in call (have 'size:', expected 'coder:')
nextScene.scaleMode = .AspectFill
scene?.view?.presentScene(nextScene, transition: transition)
}
【问题讨论】:
-
好的,
scene在哪里定义?您能否向我们展示更多代码,以帮助我们了解上下文。例如,您在此处向我们展示的代码是来自某种ViewController还是来自Scene本身? -
@pbodsk 来自视图控制器。这是它的完整脚本:pastebin.com/gzaXhJF9,这是视图:imgur.com/a/gAM0b
-
您介意将其发布到您的问题中吗...以便我们将其放在一个地方?
-
在您链接到的代码中,我可以看到对
scene的引用的唯一地方是编译器抱怨的地方。所以这就是为什么它至少抱怨......它不知道scene是什么,因为你之前没有声明过它:) -
好的,我使用 'var scene = SKScene()' 声明它,但现在它显示'Incorrect argument laben in call (have 'size:', expected 'coder:')
标签: swift sprite-kit uikit scene