假设我要创建以下手势识别器
UITapGestureRecognizer * c1 = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector([[MyGestureRecognizer ViewWasClicked1:]]; // error
[c1 setNumberOfTapsRequired:1];
[c1 setNumberOfTouchesRequired:1];
[[self view] addGestureRecognizer:c1];
但是我想在一个单独的类上调用选择器。我有方法:
+ (void)ViewWasClicked1:(UITapGestureRecognizer *)sender {
NSLog(@"click1 mouse down");
}
在MyGestureRecognizer类中。我在找什么呢?
最佳答案
语法为:
UITapGestureRecognizer * c1 = [[UITapGestureRecognizer alloc]
initWithTarget:[MyGestureRecognizer class]
action:@selector(ViewWasClicked1:)]; // error
关于objective-c - 在来自单独类的静态方法上调用选择器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10458258/