0

我有一个使用“ProMotion-formotion”gem 可以很好地工作的设置屏幕。我想将几行做成按钮,按下时会调用一个方法,例如:

  def table_data
    set_nav_bar_button :left, title: "Cancel", action: :close
    set_nav_bar_button :right, title: "Save", action: :submit

    {sections:[{
      title: 'Help',
      rows: [{
        title: "About",
        type: :string,
        editable: false,
        action: :help  #this is the sort of thing I want
      }]
    }, {
      title: 'General',
      rows: [
[...etc...]

有谁知道我怎么能做到这一点?

编辑:我在这里找到了一个可能的解决方案: 如何在 ProMotion-Formotion 中使用 .on_delete 回调

但仍然想知道在 table_data 方法中是否有办法做到这一点。

4

1 回答 1

0

弄清楚了...

{
  title: "Any Button",
  type: :button,
  key: :some_button
}

# later...
form.row(:some_button).on_tap do |row|
  # do something when tapped
end

从这里: https ://github.com/clayallsopp/formotion/blob/master/LIST_OF_ROW_TYPES.md#button

于 2015-05-11T15:35:51.187 回答