首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >更改ProMotion TableScreen布局

更改ProMotion TableScreen布局
EN

Stack Overflow用户
提问于 2016-07-06 23:41:57
回答 1查看 31关注 0票数 0

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

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

我甚至使用REPL控制台移动了TableView:

代码语言:javascript
运行
复制
rmq(4496872960).nudge d: 10

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

我的屏幕代码:

代码语言:javascript
运行
复制
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对象中添加了如下样式:

代码语言:javascript
运行
复制
def viewDidLoad
  super
  rmq(UITableViewWrapperView).apply_style(:style_for_table_wrapper)
end

因此,在我的样式表中,我可以对所有内容进行样式设置: background_color、隐藏状态,但是框架样式被忽略了。

代码语言:javascript
运行
复制
def top_home_view(st)
  st.frame = {l:20, t: 20, w: 300, h: 60}
  st.background_color = color.white
end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-07 02:52:10

正如在这个Github问题中所指出的:

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

这里的解决方案在于为TableScreen实现一个标头视图。这样我们就可以在单元格上有一个区域供我们自己使用:

定义一个table_header_view,返回一个UIView实例(必需):

代码语言:javascript
运行
复制
class HomeScreen < PM::TableScreen
  # ...
  def table_header_view
    create!(TopHomeView, :top_home_view)
  end

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

这件事要归功于https://github.com/andrewhavens

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38235536

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档