开发者

iOS - debugging tool to detect view touched

开发者 https://www.devze.com 2023-01-14 10:57 出处:网络
Wondering if anyone has written or come across a good way to log to the console the view that a touch occurred in. I know touchesEnded: can be implemented, but my problem is that something mysterious

Wondering if anyone has written or come across a good way to log to the console the view that a touch occurred in. I know touchesEnded: can be implemented, but my problem is that something mysterious is blocking touches on my views and I don't know what it is. I would just like to know what is inter开发者_运维知识库cepting the touches.

I would like to log to the console:

"Touch occurred in view: nameOfSomeUIView"


Each UITouch object has a view property described as "The view in which the touch initially occurred." You can subclass UIWindow and override the sendEvent method. In your implementation of sendEvent you can call [super sendEvent: event] and after that inspect the view properties of all the touches that belong to the event.

As a general tip: Check the hitTest method of your views if your UITouches do not behave as expected. You can override this method to see which view should receive touches.

0

精彩评论

暂无评论...
验证码 换一张
取 消