加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 17:29:01 所属栏目:百科 来源:网络整理
导读: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.setPositio
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;
    },

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读