Override UIGestureRecognizer touchBegan

I have 1 Main View and 1 SubView:

Main View> SubView

I think Main View is a β€œtheft” of events from SubView.

For example, when I click on SubView, only the Main view of the GestureRecognizer lights up.

Here is my custom GestureRecognizer (which captures every touch event):

import UIKit import UIKit.UIGestureRecognizerSubclass class MainGestureRecognizer: UIGestureRecognizer { override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) { super.touchesBegan(touches, withEvent: event); //nextResponder() ?? state = UIGestureRecognizerState.Began; } override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) { super.touchesMoved(touches, withEvent: event); //nextResponder() ?? state = UIGestureRecognizerState.Changed; } override func touchesEnded(touches: NSSet!, withEvent event: UIEvent!) { super.touchesEnded(touches, withEvent: event); //nextResponder() ?? state = UIGestureRecognizerState.Ended; } override func touchesCancelled(touches: NSSet!, withEvent event: UIEvent!) { super.touchesCancelled(touches, withEvent: event); //nextResponder() ?? state = UIGestureRecognizerState.Cancelled; } } 

Maybe I should use nextResponder , but I found only Obj-C code, for example:

[self.nextResponder concerns Began: affects the eventEvent: event];

What is the trick to pass the event to the next responder in the responder chain?

Is there a way to transfer touches to the iPhone?

So the question is, what do I need to do to make another event (SubView Event)?

Is there a function like nextResponder in Swift?

+6
source share
1 answer

Γ”h! Here is the Swift code for nextResponder :

fooobar.com/questions/977072 / ...

+1
source

Source: https://habr.com/ru/post/977070/


All Articles