Need some help. New to the forum and first post. I'm using the handlePan gesture to move a rectangle on view and is woking. I want to display the center coordinate on real time while moving the rectangle on the label topLabel.text. For some reason when I use: println ("\(view.center.y)") I can see the value update on the output window and all works corrrectly. But if I replace this line with topLabel.text = ("\(view.center.y)") it doesn't work; rectangle don't even move.
class ViewController: UIViewController {
@IBOutlet weak var topLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func handlePan(recognizer:UIPanGestureRecognizer) {
let translation = recognizer.translationInView(self.view)
if let view = recognizer.view {
view.center = CGPoint(x:view.center.x, y:view.center.y + translation.y)
topLabel.text = "\(view.center.y)"
}
recognizer.setTranslation(CGPointZero, inView: self.view)
}
}
New to swift also, of course.