Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCTableView acting weird #2049

Closed
vipsbpig opened this issue Feb 26, 2013 · 13 comments
Closed

CCTableView acting weird #2049

vipsbpig opened this issue Feb 26, 2013 · 13 comments

Comments

@vipsbpig
Copy link
Contributor

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.
2. once I drag the cell. only drag left in DirectionHorizontal ,only drag down in FillTopDown
//当cell的总高度比Table小很多的时候(例如只有1或者2 个cell),这个Tableview就变得很奇怪.
1.在TableView触摸空白的地方,它回调最后一个cell
2.只要我拖动cell ,在水平方向的模式只能往左边拖,在竖直方向只能往下拖

@dumganhar
Copy link

WHICH VERSION of cocos2d-x are you using?
THE BUG HAS BEEN FIXED on the latest codes on the github.
Did you try that?

@vipsbpig
Copy link
Contributor Author

i'm using 2.0.4, maybe I should Update my cocos2d-x.

@vipsbpig
Copy link
Contributor Author

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"

@dumganhar
Copy link

Thank you, i will check that.

@dumganhar
Copy link

Fixed at #2050.
Could you pull the latest codes and try again?
Feel free to give us your feedback. Thanks.

@vipsbpig
Copy link
Contributor Author

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?

@dumganhar
Copy link

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.

@dumganhar
Copy link

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.

@vipsbpig
Copy link
Contributor Author

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;
};

@dumganhar
Copy link

OK, I will test it. Thank you.

@dumganhar
Copy link

Fixed at #2056.
PLZ have a try.

@vipsbpig
Copy link
Contributor Author

AWESOME!!!It solved ,I like this tableView!!!Thanks a lot!! BTW ,how to closed this issue?..

@dumganhar
Copy link

I closed it.
You could close issue by clicking close button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants