objective-c - 在 RubyMotion 中使用@selector

标签 objective-c syntax rubymotion

如何将以下方法调用从 ObjectiveC 转换为 RubyMotion 语法:

[self.faceView addGestureRecognizer:[
    [UIPinchGestureRecognizer alloc] initWithTarget:self.faceView
    action:@selector(pinch:)]];

我做到了这一点:

self.faceView.addGestureRecognizer(
  UIPinchGestureRecognizer.alloc.initWithTarget(
  self.faceView, action:???))

我理解 @selector(pinch:) 指示对接收方对象 pinch 方法的委托(delegate),但我如何在 RubyMotion 中执行此操作?也许使用 block ?

最佳答案

你应该能够只使用一个字符串来指定选择器:

self.faceView.addGestureRecognizer(
  UIPinchGestureRecognizer.alloc.initWithTarget(
  self.faceView, action:'pinch'))

关于objective-c - 在 RubyMotion 中使用@selector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10486367/

相关文章:

ios - Objective-C:存储在集合中的 block 的初始化

ios - 集成 Paypal SDK for IOS 时出现 PayPal 链接错误

assembly - ARM 汇编语法样式

ios - Formotion 推广 RubyMotion

ios - 如何使用 Rubymotion 在 UITableView 中创建 facebook 提要样式卡片?

sqlite - 结合使用SQLite和Rubymotion

iphone - 如何在IBAction中传递参数?

objective-c - 在 iOS 中从 parentViewController 调用 SEL

c - "int main (vooid)"?这是如何运作的?

function - 我真的对 Haskell 中的函数声明感到困惑