Closed vipsbpig closed 11 years ago
WHICH VERSION of cocos2d-x are you using? THE BUG HAS BEEN FIXED on the latest codes on the github. Did you try that?
i'm using 2.0.4, maybe I should Update my cocos2d-x.
drag method is working fine in last code in github code
but touch the empty space is still not work as expected ,it should be callback nothing, it still say “cell touched at index: n"
Thank you, i will check that.
Fixed at https://github.com/cocos2d/cocos2d-x/pull/2050. Could you pull the latest codes and try again? Feel free to give us your feedback. Thanks.
Well,goob job!It is working fine !!
//////There is another BUG in reloaddata() function.
I use the tableView in mulit thread.The data of cell is from another thread .
When I use CCTableView::create(this, CCSizeMake(size.width - 145, 196)) to create a TableView WITHOUT loading any data in another thread.
At this MOMENT numberOfCellsInTableView(cocos2d::extension::CCTableView _table) return 0 twice;
after created the TableView , I load all data of cell and config the TableView ,and use pTableView->reloaddata();
numberOfCellsInTableView(cocos2d::extension::CCTableView table) return the right numberOfCell;
BUT IT SHOWS NOTHING until I scoll the cell. tableCellAtIndex(cocos2d::extension::CCTableView table, unsigned int idx)
only run once at the latest number.
Now, I use pTableView->setContentOffset(ccp(0,(float)196-numberOfCell_50)) to calculate the right position to force it to do scroll Function to load other cell .
Or has another way to load all cell?
When I use CCTableView::create(this, CCSizeMake(size.width - 145, 196)) to create a TableView WITHOUT loading any data in another thread.
Cocos2d-x is not thread-safe, so don't create any cocos2d-x object in another thread.
If you make sure that all the callings of cocos2d-x api is on the main thread.
And the issue still exists. Could you add the issue test
to TestCpp/TableViewTest
.
That will be easy for us to resolve it. Thanks.
I sorry that I am not familiar with github. I just paste the code here.
// on "init" you need to initialize your instance bool TableViewTestLayer::init() { if ( !CCLayer::init() ) { return false; }
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
number = 0; // here is the code I added
CCTableView* tableView = CCTableView::create(this, CCSizeMake(250, 60));
tableView->setDirection(kCCScrollViewDirectionHorizontal);
tableView->setPosition(ccp(20,winSize.height/2-30));
tableView->setDelegate(this);
this->addChild(tableView);
number = 20; // here is the code I added
tableView->reloadData();
number = 0 ; // here is the code I added
tableView = CCTableView::create(this, CCSizeMake(60, 250));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(ccp(winSize.width-150,winSize.height/2-120));
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
this->addChild(tableView);
number =20; // here is the code I added
tableView->reloadData();
// Back Menu
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(TableViewTestLayer::toExtensionsMainLayer));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
menuBack->setPosition(CCPointZero);
addChild(menuBack);
return true;
}
//and then unsigned int TableViewTestLayer::numberOfCellsInTableView(CCTableView *table) { return number; // here is the code I changed }
class TableViewTestLayer : public cocos2d::CCLayer, public cocos2d::extension::CCTableViewDataSource, public cocos2d::extension::CCTableViewDelegate { public: // etc... private: int number; };
OK, I will test it. Thank you.
Fixed at https://github.com/cocos2d/cocos2d-x/pull/2056. PLZ have a try.
AWESOME!!!It solved ,I like this tableView!!!Thanks a lot!! BTW ,how to closed this issue?..
I closed it.
You could close issue by clicking close
button.
when the Cells' total heigh is much shorter than TableView's heigh ,(like 1 or 2 cells )it starts acting weird . 1.touch the empty space in tableView,it callback the last cell.