I want to define the custom UIGestureRecognizer in Swift, but I cannot import UIGestureRecognizerSubclass and cannot override the methods of "touchesBegan", "touchesMoved", and so on.
"UIGestureRecognizerSubclass.h" is in the UIKit module, but only modules can likely be imported in Swift and header files cannot be imported.
How can I import UIGestureRecognizerSubclass and define the custom UIGestureRecognizer?
Edit:
I added the below code in Bridging-Header.h and I successfully compiled my custom gesture recognizer.
#import <UIKit/UIGestureRecognizerSubclass.h>
But this code may import "UIGestureRecognizerSubclass.h" for every swift files in my project, so I am thinking it is not the best way.
Is it right way? Is there another proper solution?
You need to add the import:
import UIKit.UIGestureRecognizerSubclass
as in:
import UIKit
import UIKit.UIGestureRecognizerSubclass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With