【问题标题】:Method does not override any method from it's superclass方法不会覆盖其超类中的任何方法
【发布时间】:2015-11-01 19:40:19
【问题描述】:

当我得到这个错误时,我正在尝试创建一个新的覆盖函数:方法没有覆盖它的超类中的任何方法

我已经尝试删除覆盖部分,但这只会给我另一个错误。

override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {

    let touch : UITouch! = touches.anyObject() as! UITouch

    location = touch.locationInView(self.view)

    person.center = location
}

override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) {

    let touch : UITouch! = touches.anyObject() as! UITouch

    location = touch.locationInView(self.view)

    person.center = location

}

【问题讨论】:

标签: swift touchesbegan touchesmoved


【解决方案1】:

正确的方法签名是:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

}

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {

}

【讨论】:

    猜你喜欢
    • 2016-12-08
    • 1970-01-01
    • 2019-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-22
    相关资源
    最近更新 更多