objective-c – 从单独的类调用静态方法的选择器

前端之家收集整理的这篇文章主要介绍了objective-c – 从单独的类调用静态方法的选择器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
假设我想创建以下手势识别器
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

猜你在找的C&C++相关文章