将按钮添加到可滚动的全景图像-iOS Swift 4

我正在设计一个iOS应用程序,它将使用户可以从全景图像视图中拾取对象。 用户将能够“环顾四周”(左右),并且需要从一侧选择一个项目。

现在的问题是,如何准确跟踪用户在图像中单击的位置?用户可以向左和向右移动,捏和拉。

不能使用Apple ARKit,此应用也会在以后为Android开发。

hia123 回答:将按钮添加到可滚动的全景图像-iOS Swift 4

因此,我给了它更多的思考和不同的方法。 答案是使用以下代码获取图像的坐标: 用户与之交互时,焦点放在什么位置都无所谓,您将获得图像中位置的坐标。 希望这对某人有帮助!

    @IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view,typically from a nib.
        let tapGestureRecognizer = UITapGestureRecognizer(target: self,action: #selector(tapAction))
        self.imageView.isUserInteractionEnabled = true
        self.imageView.addGestureRecognizer(tapGestureRecognizer)
    }

@objc func tapAction(sender: UITapGestureRecognizer) {
        let touchPoint = sender.location(in: self.imageView) // Change to whatever view you want the point for
        print(touchPoint)
    }
本文链接:https://www.f2er.com/2433400.html

大家都在问