Une partie d'un projet sur lequel je travaille nécessite de faire bouger un objet en utilisant le toucher. Je cours actuellement Swift 3.1 et Xcode 8.3.3. La 7ème ligne me donne des erreurs disant:Set <UITouch> n'a pas de membre "location"
Valeur de type
'Set<UITouch>'
n'a pas membre «location
»
mais je l'ai regardé la documentation et il est membre. Y at-il une solution de contournement? J'ai seulement besoin de déplacer l'image basée sur le toucher et le glisser.
import UIKit
class ViewController: UIViewController {
var thumbstickLocation = CGPoint(x: 100, y: 100)
@IBOutlet weak var Thumbstick: UIButton!
override func touchesBegan(_ touches:Set<UITouch>, with event: UIEvent?) {
let lastTouch : UITouch! = touches.first! as UITouch
thumbstickLocation = touches.location(in: self.view)
Thumbstick.center = thumbstickLocation
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
let lastTouch : UITouch! = touches.first! as UITouch
thumbstickLocation = lastTouch.location(in: self.view)
Thumbstick.center = thumbstickLocation
}