Cocos2D-JS TableView’s pit, call Settag, you must re-call once on the outside

tableCellAtIndex:function (table, idx) {
var cell = table.dequeueCell();
if (!cell) {
cell = new cc.TableViewCell();
//Create a small cell
var pnl_cell = this.root.getChildByName("pnl_cell").clone();
pnl_cell.setName("pnl_cell ");
pnl_cell.setPosition(cc.p(0, 0));
pnl_cell.setVisible(true);
cell.addChild(pnl_cell);

var headIcon = CMF.createHeadIcon("res/icon/gem.png", "gems");
headIcon.setPosition(cc.p(47, 66));
pnl_cell.addChild(headIcon );

pnl_cell.getChildByName("btn_choose").setTag(idx);
pnl_cell.getChildByName("btn_choose").addTouchEventListener(this.call_clickAddItem, this);
}

var pnl_cell = cell.getChildByName("pnl_cell"); //Cell control
pnl_cell.getChildByName("btn_choose").set Tag(idx); //tag must be reset
return cell;
},

tableCellAtIndex:function (table, idx) {
var cell = table.dequeueCell();
if (!cell) {
cell = new cc.TableViewCell();
//Create a small cell
var pnl_cell = this.root.getChildByName("pnl_cell").clone();
pnl_cell.setName("pnl_cell");
pnl_cell.setPosition(cc.p(0, 0));< br /> pnl_cell.setVisible(true);
cell.addChild(pnl_cell);

var headIcon = CMF.createHeadIcon("res/icon/gem.png", "gems") ;
headIcon.setPosition(cc.p(47, 66));
pnl_cell.addChild(headIcon);

pnl_cell.getChildByName("btn_choose").setTag(idx );
pnl_cell.getChildByName("btn_choose").addTouchEventListener(this.call_clickAddItem, this);
}

var pnl_cell = cell.getChildByName("pnl_cell"); / /Cell Control
pnl_cell.getChildByName("btn_choose").setTag(idx); //tag must be reset
return cell;
},

Leave a Comment

Your email address will not be published.