我如何获取用户坐标 swift

How I Can Get Users Coordinates swift

我想获取用户坐标并打印在标签中。

我该怎么做?我想在 Swift.

中完成

再见 亨利

我猜你不知道如何获取坐标!?

你应该制作一个 imageView 然后在你的 ViewController:

@IBOutlet weak var imageView: UIImageView!

var coordinates = CGPoint.zero

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    if let touch = touches.first{
        coordinates = touch.location(in: imageView)
        print(coordinates)
        textLabel.text = "\(coordinates)"
    }
}

然后您将打印坐标并可以将它们放入标签中。