Daniel Klöck
Daniel Klöck

Reputation: 21137

Handling touches

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)

Upvotes: 0

Views: 352

Answers (1)

Daniel Klöck
Daniel Klöck

Reputation: 21137

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];

Upvotes: 1

Related Questions