确定所有触摸都处于哪个视图触摸 [英] Determining which view touch was in for all touches

查看:64
本文介绍了确定所有触摸都处于哪个视图触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要确定整个应用程序发生了哪些视图触摸,目的是记录触摸,以便以后可以浏览日志并确定用户的操作.我知道我可以继承UIView并重写touchesBegan/Ended来记录这些内容,但是我在Interface Builder中使用了UIButton,UISlider等的许多实例,因此除非我也将这些类也进行了子类化,否则它将无法工作.

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.

用于确定自上次触摸以来的时间(对于待机屏幕超时方法),我已经具有UIApplication子类,并且sendEvent:被覆盖.我唯一可以看到的方法就是遍历主窗口的子视图,在传递给sendEvent:的UIEvent上调用touchesForView :,但是我想知道是否有一种更干净的方法来判断触摸了哪个视图(是否通过sendEvent:方法).谢谢!

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!

推荐答案

看看这是否可以满足您的要求:

See if this will do what you want: Observing pinch multi-touch gestures in a UITableView

这篇关于确定所有触摸都处于哪个视图触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆