Подтвердить что ты не робот

Использование @selector в 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, но как бы это сделать в RubyMotion? Возможно, используя блок?

4b9b3361

Ответ 1

Вы можете просто использовать строку для указания селектора:

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