report a bug of CTableView

report a bug of CTableView
0.0 0



i create 10 cells in tableview(just show number in cell),

now,every cell’s idx is 0~9 in m_pIndices

then do nothing,just click a button to delete the cell one by one,

when i clicked 6 times,i can’t delete the cell forever

then i checked the source code of CCTableView,i think it should be a bug

//remove first

//    [m_pIndices shiftIndexesStartingAtIndex:idx+1 by:-1];

//in the for sequence,some cells' idx will be adjusted based on the deleted cell
//but the cells's idx in m_pIndices were not adjusted at the sametime,
//for the reason,when deleted 6 times,CCTableView can't find which idx=6's cell in m_pIndices
    for (unsigned int i=m_pCellsUsed->count()-1; i > newIdx; i--) {
        cell = (CCTableViewCell*)m_pCellsUsed->objectAtIndex(i);
        this->_setIndexForCell(cell->getIdx()-1, cell);

//my resolution:

void CCTableView::_setIndexForCell(unsigned int index, CCTableViewCell *cell)
    cell->setAnchorPoint(ccp(0.0f, 0.0f));
    int formerIdx = cell->getIdx();//
        int nowIdx = index;//
        std::set::iterator it = m_pIndices->find(formerIdx);//
        if(it != m_pIndices->end()){//

“//” was new added


Unfortunately, The CCTableCiew is not very stable so far , at least in my opinion . I recommend you to use the CCListView in version 2.0 of cocos2d-x , I think it’s more useful and easier , for example , you can scroll to destination row by using scrollToBack method , and you can set different content size of each row(CCTableView can’t do this) ,etc. I don’t know why they removed it , but I retained it in my project and improved it.