【问题标题】:Swift - Shows an error for term "inView"Swift - 显示术语“inView”的错误
【发布时间】:2016-12-22 18:08:12
【问题描述】:
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'" 。在这种情况下我该怎么办?

【问题讨论】:

  • 你应该使用 self.view 而不仅仅是 view

标签: swift xcode view position


【解决方案1】:

Coin 类不继承自具有视图属性的类。假设你想在flip coin方法中引用视图,给函数添加一个参数传入。

func coinFlip(inView view: UIView) 

【讨论】:

  • 感谢您的帮助!
猜你喜欢
  • 2014-01-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-08
相关资源
最近更新 更多