【问题标题】:Rubymotion: Automatically submitting a formotion form when form changedRubymotion:表单更改时自动提交表单
【发布时间】:2013-10-02 21:06:05
【问题描述】:

当我更改表单中的字段时,我想将表单提交到服务器。有人知道是否有更改回调或类似的东西吗?

我的表格:

class SettingsScreen < PM::FormotionScreen
  title "Settings"
  tab_bar_item title: "Settings", icon: 'settings'

  def table_data
    {
      sections: [
        {
          title: "Settings",
          rows: [
            {
              title: "Start Date",
              key: :start_date,
              type: :date,
              format: :medium
            }, {
              title: "End Date",
              key: :end_date,
              type: :date,
              format: :medium
            }
          ]
        }
      ]
    }
  end

  def on_load
    self.form.on_submit do |form|
      p "submitting!"
    end
  end
end

【问题讨论】:

    标签: ios ios7 rubymotion formotion


    【解决方案1】:

    一种方法是使用RMQ 来查看值。

    你可以用它做什么的一个例子(未经测试):

    rmq(UITextView).on(:change) do |sender|
      save_something @form.render
    end
    

    行上有一个未记录的(据我所知)on_change 方法,但我不完全确定如何首先获取行。

    https://github.com/clayallsopp/formotion/search?q=on_change&ref=cmdform

    【讨论】:

      【解决方案2】:

      这是我正在开发的当前应用程序的一个示例。我正在使用 Bubblewrap 的观察者,但我想 RMQ 也会这样工作。您可以在该观察块中放置您喜欢的任何调用。另外,我确实记得 Jamon 提到的未记录的工作方法——它们只是不能满足我的特定需求。在实际表单之外获取行更麻烦,但也可行。

      section.build_row do |row|
          row.title = "Percentage"
      
          row.type = :static
          row.value = @percentage.to_i.to_s + ' %' || ''
      
        end
        section.build_row do |row|
          row.title = ""
          row.key = :percentage
          row.type = :slider
          row.range = (1..100)
          row.value = @percentage || 50
          observe(row, "value") do |old_value, new_value|
              row.previous_row.value = new_value.to_i.to_s + ' %'
          end
        end
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-03-31
        • 1970-01-01
        • 2015-09-24
        • 1970-01-01
        • 2020-11-23
        • 2014-07-19
        相关资源
        最近更新 更多