无论“视图”是什么,如何获取触摸坐标 我可能摸过?

发布于 2024-08-02 02:20:59 字数 304 浏览 7 评论 0原文

在我的 ViewController 中,我有一个 UITableView,其中包含一些自定义单元格。 当我触摸一个单元格时,我想将触摸坐标获取到我的 UIViewController 中。 问题是,我只能从没有被 UITableView 占据的屏幕部分获取坐标...,每当我的触摸落在 UITableView 的屏幕部分时,我的坐标就会被 NSLogged 返回为 (0.000, 0.000)。 无论哪个视图发生触摸,如何获取屏幕坐标? 我是从 UIScreen 开始吗? UIWindow?...

问题:如何获取触摸坐标,无论我可能触摸过什么“视图”?

In my ViewController, I have a UITableView with some custom cells in it. When I touch a cell I want to get the touch coordinates right there into my UIViewController. The problem is, I can only get coordinates from parts of the screen not occupied by the UITableView..., Whenever my touch falls in the parts of the screen with the UITableView, my coords are NSLogged back as (0.000, 0.000). How can I get coordinates of the screen REGARDLESS of whichever view happened to get the touch? Do I start from UIScreen? UIWindow?...

Question: How to get touch coordinates REGARDLESS of what "view" I may have touched?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回梦 2024-08-09 02:20:59

您可以让 UITableView 选择触摸并将其报告给其视图控制器,视图控制器又可以将其报告给其他视图控制器或类似的东西。 我不确定设置 tableView opaquew 是否允许触摸到下面的触摸,但如果没有,您可以尝试一下。

You can have UITableView pick touches up and report them to its viewcontroller which can in turn report it to the other view controler, or something of that matter. Im not sure if setting the tableView opaquew will allow touches to go to the underneath touch, but you can try that if you havent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文