let's say I want to create the following gesture recognizer
UITapGestureRecognizer * c1 = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector([[MyGestureRecognizer ViewWasClicked1:]]; // error
[c1 setNumberOfTapsRequired:1];
[c1 setNumberOfTouchesRequired:1];
[[self view] addGestureRecognizer:c1];
but I want to call the selector on a separate class. I have the method:
+ (void)ViewWasClicked1:(UITapGestureRecognizer *)sender {
NSLog(@"click1 mouse down");
}
in the class MyGestureRecognizer. is it possible to what am I looking for?
The syntax is:
UITapGestureRecognizer * c1 = [[UITapGestureRecognizer alloc]
initWithTarget:[MyGestureRecognizer class]
action:@selector(ViewWasClicked1:)]; // error
To check for and call static methods, you can do this:
SEL staticMethodSelector = @selector(methodName);
if ([[ClassName class] respondsToSelector:staticMethodSelector]) {
[[ClassName class] performSelector:staticMethodSelector];
}
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