如何在iOS swift中获取分接点(坐标)

如何在iOS swift中获取分接点(坐标),第1张

概述我正试图在屏幕上获取触摸的坐标,以显示d出菜单 如何在页面视图控制器中使用 我在这做错了什么? override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { if let touch = touches.first { let position = touch.locationInV 我正试图在屏幕上获取触摸的坐标,以显示d出菜单

如何在页面视图控制器中使用

我在这做错了什么?

overrIDe func touchesBegan(touches: Set<UItouch>,withEvent event: UIEvent?) {    if let touch = touches.first {      let position = touch.locationInVIEw(vIEw)      print(position)    }  }
解决方法 在PageVIEwController中,如果要d出窗口

在vIEwDIDLoad中:

let tap = UITapGestureRecognizer(target: self,action: "showMoreActions:")    tap.numberOfTapsrequired = 1    vIEw.addGestureRecognizer(tap)

使页面视图控制器继承UIGestureRecognizerDelegate,然后添加:

func showMoreActions(touch: UITapGestureRecognizer) {        let touchPoint = touch.locationInVIEw(self.vIEw)        let DynamicVIEw = UIVIEw(frame: CGRectMake(touchPoint.x,touchPoint.y,100,100))        DynamicVIEw.backgroundcolor=UIcolor.greencolor()        DynamicVIEw.layer.cornerRadius=25        DynamicVIEw.layer.borderWIDth=2        self.vIEw.addSubvIEw(DynamicVIEw)}

UIPageViewController with TouchEvent

总结

以上是内存溢出为你收集整理的如何在iOS swift中获取分接点(坐标)全部内容,希望文章能够帮你解决如何在iOS swift中获取分接点(坐标)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1106177.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存