function TurntableLayer:Rank_scrollViewDidScroll(view)
print("scrollViewDidScroll", self.rankTableView:getContentOffset().y);
end
function TurntableLayer:Rank_cellSizeForTable(view, idx)
local width = self._recordPanel:getContentSize().width;
local height = self._recordPanel:getContentSize().height;
print("cellSizeForTable", width, height)
return width, height;
end
function TurntableLayer:Rank_numberOfCellsInTableView(view)
print("numberOfCellsInTableView", table.nums(self.AllRecord))
return table.nums(self.AllRecord);
end
function TurntableLayer:Rank_tableCellAtIndex(view, idx)
print("tableCellAtIndex", idx);
local index = idx + 1;
local cell = view:dequeueCell();
if nil == cell then
local rankItem = self._recordPanel:clone();
rankItem:setPosition(cc.p(0, 0));
if rankItem then
self:setRankInfo(rankItem, index);
end
cell = cc.TableViewCell:new();
cell:addChild(rankItem);
else
local rankItem = cell:getChildByName("Panel_record");
self:setRankInfo(rankItem, index);
end
return cell;
end
function TurntableLayer:setRankInfo(rankItem, index)
local infoTable = self.AllRecord[index];
-- 获取中奖时间和内容
local RecordID = infoTable.ID;
local RecordName = infoTable.sName;
local RecordPrizeID = infoTable.prizeID;
local prizeWord = "";
prizeWord = g_DictTable[Prize_Begin + RecordPrizeID + 1]["Content"];
-- 中奖奖品
local prizeType = rankItem:getChildByName("Text_lipin");
if prizeType then
prizeType:setString(prizeWord)
end
-- 中奖姓名
local sName = rankItem:getChildByName("Text_date");
if ID then
local sNameTemp = RecordName;
sNameTemp = CommonFunc_GetSuitNickName(sNameTemp);
ID:setString(sNameTemp)
end
-- 中奖ID
local ID = rankItem:getChildByName("Text_ID");
if ID then
ID:setString("ID" .. RecordID)
end
end
-- 获取样本战绩信息的容器
self.rankTableView = cc.TableView:create(cc.size(sizeScroll.width, sizeScroll.height));end
if self.rankTableView then
self.rankTableView:setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL);
self.rankTableView:setVerticalFillOrder(cc.TABLEVIEW_FILL_BOTTOMUP);
self.rankTableView:setPosition(cc.p(0, 0));
self.rankTableView:setDelegate();
self.rankTableView:registerScriptHandler(handler(self, self.Rank_scrollViewDidScroll), cc.SCROLLVIEW_SCRIPT_SCROLL);
-- 滚动时的回调函数
self.rankTableView:registerScriptHandler(handler(self, self.Rank_cellSizeForTable), cc.TABLECELL_SIZE_FOR_INDEX);
-- 列表项的尺寸
self.rankTableView:registerScriptHandler(handler(self, self.Rank_tableCellAtIndex), cc.TABLECELL_SIZE_AT_INDEX);
-- 创建列表项
self.rankTableView:registerScriptHandler(handler(self, self.Rank_numberOfCellsInTableView), cc.NUMBER_OF_CELLS_IN_TABLEVIEW);
-- 列表项的数量
self.rankTableView:reloadData();
self.Panel_allrecord:addChild(self.rankTableView);