0

Rubymotion を使用して iOS アプリを作成しています。メール コンポーザーでビルドを使用していますが、キャンセル デリゲート メソッドの作成に問題があります。

Objective C では次のようになります。

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{

[controller dismissModalViewControllerAnimated:YES];

}

これはRubyで開始した方法ですが、間違っています:

    def MFMailComposeViewController(didFinishWithResult:lambda{ |error|

    self.dismissModalViewControllerAnimated(true)

  })

Objective C から Ruby に変換するには助けが必要です。

4

1 に答える 1

3

あくまでも通常の方法です。ラムダは不要です。

また、RubyMotion ドキュメントごとにエラー ポインターが必要です: http://www.rubymotion.com/developer-center/guides/runtime/#_pointers

error_ptr = Pointer.new(:object)
def mailComposeController(controller, didFinishWithResult:result, error: error_ptr)
  self.dismissModalViewControllerAnimated(true)
end
于 2012-12-14T23:59:44.250 に答える