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
  • 相关阅读:
    open stack总结
    Nginx操作命令
    Nginx 配置详解
    Linux 常用命令-- top
    CEPH 使用SSD日志盘+SATA数据盘, 随OSD数目递增对性能影响的递增测试
    MyCat水平分库
    MyCat垂直分库
    MyCat基本知识
    utf8mb4复杂昵称问题
    Power安装linux-BIG ENDIAN mysql编译安装
  • 原文地址:https://www.cnblogs.com/dmc-nero/p/14184732.html
Copyright © 2011-2022 走看看