确定所有触摸属于哪个视图触摸

发布于 2024-09-27 12:17:43 字数 376 浏览 0 评论 0原文

我想确定整个应用程序中发生了哪些视图触摸,以便记录触摸,以便我稍后可以查看日志并确定用户做了什么。我知道我可以子类化 UIView 并覆盖 TouchBegan/Ended 来记录这些,但我在 Interface Builder 中使用了 UIButton、UISlider 等的许多实例,因此除非我也子类化这些类,否则这是行不通的。

为了确定自上次触摸以来的时间(对于空闲屏幕超时方法),我已经有 UIApplication 子类和 sendEvent: 重写。我能看到做我想做的事情的唯一方法是迭代主窗口的子视图,在传递到 sendEvent: 的 UIEvent 上调用 TouchesForView: ,但我想知道是否有一种更清晰的方法来判断哪个视图被触摸(无论是通过或不通过 sendEvent: 方法)。谢谢!

I want to determine which view touches occurred in for the entire application, for the purpose of logging touches so that I can go through the logs later and determine what the user did. I know I could subclass UIView and override touchesBegan/Ended to log those, but I am using many instances of UIButton, UISlider, etc in Interface Builder so that wouldn't work unless I also subclassed those classes.

For determining the time since last touch (for an idle screen timeout method) I already have UIApplication subclasses and sendEvent: overridden. The only way I can see to do what I want is to iterate through the main window's subviews, calling touchesForView: on the UIEvent passed into sendEvent:, but I was wondering if there was a cleaner way to tell which view was touched (whether it's through the sendEvent: method or not). Thanks!

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

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

发布评论

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

评论(1

独守阴晴ぅ圆缺 2024-10-04 12:17:43

看看这是否会达到您想要的效果:观察捏多- UITableView 中的触摸手势

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