开发者

Handling touches

开发者 https://www.devze.com 2023-01-10 13:25 出处:网络
I have a UIView subclass with several subviews and I want to handle these events in the class: 开发者_运维问答touchesBegan:withEvent:

I have a UIView subclass with several subviews and I want to handle these events in the class:

but I also want these event to be called at the subviews. How can I accomplish that?

(I have already tried with hitTest, but I only get the touchesBegan event and no touches are send with the method)


I have managed to solve it by overriding the following method at the main window:

- (void)sendEvent:(UIEvent*)anEvent

I also check if it is the right event with through

if ([[[anEvent allTouches] anyObject] phase] == UITouchPhaseBegan)

I do the same for UITouchPhaseMoved and UITouchPhaseEnded, execute my custom code and then send [super sendEvent:anEvent];

0

精彩评论

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

关注公众号