cc.TableView 里面的
tableCellAtIndex:function (table, idx) {
var cell = table.dequeueCell();
的 if (!cell)
判断错误。
情况如下:n为底部显示的item,向上拖动时,n+1应该为 cell!=null,但此时获取的cell==null,因此不能正确显示数据。请问大家这是什么原因?
cc.TableView 里面的
tableCellAtIndex:function (table, idx) {
var cell = table.dequeueCell();
的 if (!cell)
判断错误。
情况如下:n为底部显示的item,向上拖动时,n+1应该为 cell!=null,但此时获取的cell==null,因此不能正确显示数据。请问大家这是什么原因?
请问cc.tableView怎么使用的
参考自带例子
这个没有自带例子的
在sample/extension/tabletest中有测试例。
3.1版本是没有的,只有listView的。。
请问你使用的是哪个版本的引擎 有一个版本是有问题的
亲身经历
楼主,能否将你的代码贴出来
好像是因为每个cell在拉出来的时候都会被重绘,你能取到的就只有当前显示的这些cell值
//tabelview
var tableView = new cc.TableView(this, cc.size(600, 60));
tableView.setDirection(cc.SCROLLVIEW_DIRECTION_HORIZONTAL); //设置table 方向
tableView.x = 20;
tableView.y = size.height / 2 - 150;
tableView.setDelegate(this);
this.addChild(tableView);
tableView.reloadData(); //加载table
this._tabelview = tableView;
scrollViewDidScroll:function (view) {
},
scrollViewDidZoom:function (view) {
},
//每个cell 触摸事件
tableCellTouched:function (table, cell) {
cc.log("cell touched at index: " + cell.getIdx());
this._tabelview.removeCellAtIndex(cell.getIdx());
this._tabelNumber = this._tabelNumber-1;
},
//设置编号为 idx 的cell的大小
tableCellSizeForIndex:function (table, idx) {
//if (idx == 2) {
// return cc.size(100, 100);
//}
console.log("tableCellSizeForIndex: "+idx);
return cc.size(50, 60);
},
// 由于tableview是动态获取数据的,该方法在初始化时会被调用一次,之后在每个隐藏的cell显示出来的时候都会调用
tableCellAtIndex:function (table, idx) {
console.log("tableCellAtIndex|: "+idx);
var strValue = idx.toFixed(0);
var cell = table.dequeueCell();
var label;
if (!cell) {
cell = new CustomTableViewCell();
var sprite = new cc.Sprite(res.ccicon);
sprite.anchorX = 0;
sprite.anchorY = 0;
sprite.x = 0;
sprite.y = 0;
cell.addChild(sprite);
label = new cc.LabelTTF(strValue, "Helvetica", 20.0);
label.x = 0;
label.y = 0;
label.anchorX = 0;
label.anchorY = 0;
label.tag = 123;
cell.addChild(label);
} else {
label = cell.getChildByTag(123);
label.setString(strValue);
}
return cell;
},
numberOfCellsInTableView:function (table) { // 设置 tabelview 的cell 个数
return this._tabelNumber;
}
而我需要删除后 能够自动刷新,请问? 怎么办呢 删除后 位置错乱 没有重新刷新、、、、能不能跟oc 中的一样 删除刷新 还能自定义删除按钮、、、、