0

我在 ProMotion 文档和示例中到处查看,但我无法找到更改 TableScreen 布局的方法,特别是 TableView 单元格的垂直起始位置。

我的屏幕顶部有一个 UIView 来显示一些按钮,并且 TableView 单元格应该从下面开始,但现在它们在彼此之上。

我什至设法使用 REPL 控制台移动 TableView:

rmq(4496872960).nudge d: 10

4496872960我的对象的 id 在哪里UITableViewWrapperView,但我不知道在代码中将此对象的布局坐标放在哪里。

我的屏幕代码:

class HomeScreen < PM::TableScreen
  title I18n.t("home_screen.title")
  tab_bar_item title: I18n.t("home_screen.title"), item: "icon-home_32x32.png"
  row_height :auto, estimated: 30
  stylesheet HomeScreenStylesheet

  def on_load
    @matches = [{attributes: {status: "dummy1", player2: {email: "dummy1@match.com"}}},{attributes: {status: "dummy2", player2: {email: "dummy2@match.com"}}}]
    append(TopHomeView, :top_home_view)
    set_nav_bar_button :left, title: I18n.t("home_screen.sign_out_label"), image: image.resource("icon-logout-32x32.png"), action: :sign_out
    set_nav_bar_button :right, title: (Auth.current_user ? Auth.current_user["email"] : ""), image: image.resource("icon_user_50x50.png"), action: :open_profile

    load_async
  end

  def table_data
    [{
      cells: @matches.map do |match|
        {
          title: match[:attributes][:player2][:email],
          subtitle: match[:attributes][:status],
          action: :play_round,
          arguments: { match: match }
        }
      end
    }]
  end

编辑:

我一直在尝试解决这个问题,现在我为我的UITableViewWrapperView对象添加了一个样式,如下所示:

def viewDidLoad
  super
  rmq(UITableViewWrapperView).apply_style(:style_for_table_wrapper)
end

因此,在我的样式表中,我可以设置所有内容的样式:背景颜色、隐藏状态,但框架样式只是被忽略了。

def top_home_view(st)
  st.frame = {l:20, t: 20, w: 300, h: 60}
  st.background_color = color.white
end
4

1 回答 1

0

如本 Github 问题所示:

https://github.com/infinitered/ProMotion/issues/784#issuecomment-230962988

这里的解决方案在于为 TableScreen 实现一个 Header 视图。这让我们在单元格顶部有一个区域供我们自己使用:

定义返回 UIView 实例的 table_header_view(必需):

class HomeScreen < PM::TableScreen
  # ...
  def table_header_view
    create!(TopHomeView, :top_home_view)
  end

请注意,“bang 方法”(创建!)将返回 UIView 的一个实例。

归功于https://github.com/andrewhavens来解决这个问题

于 2016-07-07T02:52:10.690 回答