Promotion :: FormotionScreen将on_touch操作添加到行

时间:2015-05-11 11:56:25

标签: rubymotion rubymotion-promotion

我有一个设置屏幕,可以很好地使用" ProMotion-formotion"宝石。我想将几行放入按钮中,按下时会调用方法,例如:

  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...]

任何人都知道如何实现这一目标?

编辑:我在这里找到了一个可能的解决方案: How to use .on_delete callback in ProMotion-Formotion

但仍然想知道是否有办法在table_data方法中执行此操作。

1 个答案:

答案 0 :(得分: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