0

我对 ruby​​motion 和 Promotion 很陌生,如果这个问题很愚蠢,我很抱歉:) 我找不到任何信息如何在点击后操纵单元格的高度。有人知道怎么做吗?非常感谢

class TimeOffsScreen < ProMotion::TableScreen

  def table_data
    TimeItem.all.map do |item|
      {
        title: item.name,
        action: :open_time_item,
        arguments: { item: item },
        editing_style: :delete,
        height: 90
      }
    end
  end

  def open_time_item(item)
    # Set height of this table cell
  end

end
4

1 回答 1

2

目前没有很好的方法来做到这一点。实现它的一种方法是访问散列中的数据,然后刷新表数据。

顺便说一句,我注意到你的代码中有一个错误。您需要提供一组包含单元格的部分。

我在这里举了一个如何做到这一点的例子,但你需要验证它是否有效。

def table_data
  @time_items ||= TimeItem.all
  [{
    cells: @time_items.map do |item|
      { 
        title: item.name,
        action: :open_time_item,
        arguments: { item: item },
        editing_style: :delete,
        height: item.height || 90
      }
    end
  }]
end

def open_time_item(item)
  item.height = 180 # .height can be a temporary attr_accessor with no persistence
  update_table_data
end
于 2013-10-16T21:49:41.893 回答