cocos2d-js之tableView的一个坑,调用setTag,必须在外面要重新调用一次setTag

 tableCellAtIndex:function (table, idx) {
        var cell = table.dequeueCell();
        if (!cell) {
            cell = new cc.TableViewCell();
            //创建小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", "宝石");
            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");     //单元格控件
        pnl_cell.getChildByName("btn_choose").setTag(idx);  //必须重新设置tag
        return cell;
    },

猜你喜欢

转载自blog.csdn.net/zwcwu31/article/details/80040946