0

ProMotion のドキュメントと例を隅々まで調べましたが、TableScreen レイアウト、特に TableView セルの垂直方向の開始位置を変更する方法が見つかりません。

画面の上部にいくつかのボタンを表示する UIView があり、TableView セルはその下から開始する必要がありますが、現在は互いに重なっています。

REPL コンソールを使用して TableView を移動することさえできました。

rmq(4496872960).nudge d: 10

where4496872960はオブジェクトの 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

したがって、私のスタイルシートでは、background_color、非表示のステータスなど、すべてのスタイルを設定できますが、フレーム スタイルは無視されます。

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 のヘッダー ビューを実装することにあります。これにより、セルの上に独自に使用する領域を作成できます。

UIView のインスタンスを返す table_header_view を定義します (必須):

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

「bang メソッド」(create!) は UIView のインスタンスを返すことに注意してください。

これをクリアするためのクレジットはhttps://github.com/andrewhavensにあります

于 2016-07-07T02:52:10.690 に答える