如何将以下方法调用从 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/