2016-07-06 39 views
0

我在ProMotion文檔和示例中查找了各處,但我無法找到更改TableScreen佈局的方法,特別是TableView單元的垂直起始位置。更改ProMotion TableScreen佈局

我有一個UIView在我的屏幕頂部顯示一些按鈕,並且TableView單元格應該從下面開始,但現在它們彼此重疊。

我甚至設法使用REPL控制檯移動的TableView:

rmq(4496872960).nudge d: 10 

其中4496872960是我UITableViewWrapperView對象的ID,但我不知道放在哪裏佈局座標此對象代碼。

我的屏幕代碼:

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: "[email protected]"}}},{attributes: {status: "dummy2", player2: {email: "[email protected]"}}}] 
    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 

回答

0

在本Github的問題表示:

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

這裏的解決之道在於實現了TableScreen頁眉視圖。這讓我們有一個區域,對細胞的頂部爲我所用:

定義table_header_view返回一個UIView的實例(必填項):

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

注意,「砰方法」(創造! )將返回一個UIView的實例。

積分爲https://github.com/andrewhavens清除此項增加