zoukankan      html  css  js  c++  java
  • cocos2dx tableView 的使用

                ---创建tabView
                ---@param size {number,height:number}
                ---@param funcMap TabViewFuncMap
                ---@return TableView
                local function create_tableView(size, funcMap)
                    local tableView = cc.TableView:create(size)
                    tableView:setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL)
                    tableView:setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN)
                    tableView:setDelegate()
                    tableView:setAnchorPoint(0, 1)
                    tableView:registerScriptHandler(funcMap.NUMBER_OF_CELLS_IN_TABLEVIEW, cc.NUMBER_OF_CELLS_IN_TABLEVIEW)
                    tableView:registerScriptHandler(funcMap.SCROLLVIEW_SCRIPT_SCROLL, cc.SCROLLVIEW_SCRIPT_SCROLL)
                    tableView:registerScriptHandler(funcMap.TABLECELL_TOUCHED, cc.TABLECELL_TOUCHED)
                    tableView:registerScriptHandler(funcMap.TABLECELL_SIZE_FOR_INDEX, cc.TABLECELL_SIZE_FOR_INDEX)
                    tableView:registerScriptHandler(funcMap.TABLECELL_SIZE_AT_INDEX, cc.TABLECELL_SIZE_AT_INDEX)
                    return tableView
                end
    
    
                local function createTabView(size)
                    local function scrollViewDidScroll1(view)
                        -- print("=========  scrollViewDidScroll1 滚动事件")
                       
                    end
                    local function tableCellTouched(table, cell)
                        -- print("=========  tableCellTouched  单元格点击事件")
                    end
                    ---@param table TableView
                    local function cellSizeForTable(table, idx)
                        -- print("=========  cellSizeForTable  单元格大小事件")
                        return 100, 100
                    end
                    ---@param table TableView
                    local function tableCellAtIndex(table, idx)
                        local index = idx + 1
                        local tabel_cell = table:dequeueCell()
                        -- print("=========  tableCellAtIndex  单元格创建事件", index)
            
                        ---使用缓存池不使用分帧的方式
                        local function usePoolNoFenZhen()
                            local data = self.chat_data[index]
                            --初始化
                            if nil == tabel_cell then
                                tabel_cell = cc.TableViewCell:new()
                                local itemCom = self:get_chat_item_by_data(data, index)
                                tabel_cell:addChild(itemCom.view)
                            else
                                tabel_cell:removeAllChildren()
                                ---@type ChatListItem|ChatNotice
                                local itemCom = self:get_chat_item_by_data(data, index)
                                itemCom:update_all(data, self.channel)
                                tabel_cell:addChild(itemCom.view)
                            end
                            return tabel_cell
                        end
            
                        local tabel_cell = usePoolNoFenZhen()
                        return tabel_cell
                    end
                    local function numberOfCellsInTableView(table)
                        -- print("=========  numberOfCellsInTableView  单元格数量")
                        local dataLen = #self.chat_data
                        return dataLen
                    end
            
                    local funcMap = TabViewFuncMapSS()
                    funcMap.NUMBER_OF_CELLS_IN_TABLEVIEW = numberOfCellsInTableView
                    funcMap.SCROLLVIEW_SCRIPT_SCROLL = scrollViewDidScroll1
                    funcMap.TABLECELL_TOUCHED = tableCellTouched
                    funcMap.TABLECELL_SIZE_FOR_INDEX = cellSizeForTable
                    funcMap.TABLECELL_SIZE_AT_INDEX = tableCellAtIndex
                    local tableView = create_tableView(size, funcMap)
            
                    return tableView
                end
  • 相关阅读:
    linux 安装Python3
    MYSQL 字符集设置(终端的字符集)
    Linux LVM Logical Volume Management 逻辑卷的管理
    oracle 重命名和重定位数据文件(Oracle Renaming and Relocating Datafiles)
    Azkaban编译
    基于hive的transform实现自定义分隔符数据导出
    MapReduce优化设置
    hive.groupby.skewindata环境变量与负载均衡
    hive的基本操作
    Shell 数组的定义和使用
  • 原文地址:https://www.cnblogs.com/dmc-nero/p/14184732.html
Copyright © 2011-2022 走看看