Handling touches
-
26-09-2019 - |
문제
I have a UIView subclass with several subviews and I want to handle these events in the class:
- touchesBegan:withEvent:
- touchesMoved:withEvent:
- touchesEnded:withEvent:
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];
제휴하지 않습니다 StackOverflow