gpt4 book ai didi

Swift - 显示术语 "inView"的错误

转载 作者:行者123 更新时间:2023-11-28 12:34:21 24 4
gpt4 key购买 nike

import SpriteKit
import UIKit
import Foundation

class GameScene: SKScene {

let coin = Coin()

override func didMoveToView(view: SKView) {
/* Setup your scene here */
coin.coinFlip(inView view: UIView)

}

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

override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
}
}

Xcode 不允许我放置“coinFlip”函数!它说我必须在“inView”之后加一个逗号,然后它说“Use of unresolved identifier 'inView'”。在这种情况下我该怎么办?

最佳答案

Coin 类不继承自具有 View 属性的类。假设您想在抛硬币方法中引用 View ,向函数添加一个参数以将其传入。

func coinFlip(inView view: UIView) 

关于Swift - 显示术语 "inView"的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41289331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com