如何在ProMotion-Formotion中使用.on_delete回调

时间:2013-07-27 14:42:16

标签: rubymotion

我将ProMotion与PM :: FormotionScreen屏幕一起使用。

如何在ProMotion中使用Formotion中的行.on_delete callback

我有这个table_data方法

  def table_data
    {
      sections: [{
          rows: [

          {
          title: "URL",
          key: :url,
          placeholder: "http://myapp/dj_mon/",
          action: :delete_account,
          deletable: true,
          type: :string,
          auto_correction: :no,
          auto_capitalization: :none
          }

          ]
        }]
    }
  end

屏幕截图:http://i.stack.imgur.com/e1dlu.png

1 个答案:

答案 0 :(得分:2)

您必须使用DSL:

,而不是使用哈希来初始化Formotion表单
form = Formotion::Form.new

form.build_section do |section|
  section.build_row do |row|
    row.title               = 'URL'
    row.key                 = :url
    row.placeholder         = "http://myapp/dj_mon/"
    row.type                = :string
    row.auto_correction     = :no
    row.auto_capitalization = :none
    row.deletable           = true

    row.on_tap do |row|
      p "I'm tapped!"
    end

    row.on_delete do |row|
     p "I'm called before the delete animation"
    end
  end
end