1. Create TableView
Self.uiranklist = cc. Tableview:create (Cc.size (720, 500))
Self.uiRankList:setDirection (CC. scrollview_direction_vertical)
Self.uiRankList:setPosition (CC.P (0,220))
Self.uiRankList:setVerticalFillOrder (CC. Tableview_fill_topdown)
Parameter description:
TableView the viewable area size is 720*500
Vertical direction of scrolling
Cell fill direction to fall from top
2, need to rewrite the method:
Self.uiRankList:registerScriptHandler (function (table) return END,CC. Number_of_cells_in_tableview)
Self.uiRankList:registerScriptHandler (function (Table,cell) Self:clickcell (Table,cell) end,cc. tablecell_touched)
Self.uiRankList:registerScriptHandler (function (TABLE,IDX) return 720,list_cell_h end,cc. Tablecell_size_for_index)
Self.uiRankList:registerScriptHandler (function (table, IDX) return Self:updatecell (table, idx) end,cc. Tablecell_size_at_index)
Self.uiRankList:registerScriptHandler (function (table) self:scrollviewdidscroll (table) end,cc. Scrollview_script_scroll)
Description
Returns the number of cells
Click the cell's callback function
The size of a cell
Refresh function for cell
TableView scrolling Function callback
3, about TableView
The difference between TableView and Listview,scrollview is that it does not create all the cells, but the visible area can show a few, then create so many more, and when scrolling, the cells are refilled according to the IDX, Then refresh the cell's UI information
To get where TableView scrolled, just call TableView's Getcontentoffset () method, which can be used to fetch data to the server again when the leaderboard is scrolled to the bottom
QUICK-COCOS2DX TableView Usage