确定所有触摸属于哪个视图触摸
我想确定整个应用程序中发生了哪些视图触摸,以便记录触摸,以便我稍后可以查看日志并确定用户做了什么。我知道我可以子类化 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这是否会达到您想要的效果:观察捏多- UITableView 中的触摸手势
See if this will do what you want: Observing pinch multi-touch gestures in a UITableView