So I’m writing some code with cocos2d and I want to do it with SWTableView, problem is there is some really weird population bug with how it populates the screen vertically.
I’ll try to represent it using numbers below ex. 4 = a place where a cell can be, 4* = a cell has been placed there.
Lets say my screen right now is
1
2
3
4
After I populate it with 3 items it looks like this
1
2*
3*
4*
Basically how I created the Table has the origin at the bottom left, and not the top left which is where I want it to be. I know setVerticalFillOrder can change the order of what data is populated first, but I’ved tried both Topdown and BottopUp and both has that space at the top.
Below is how I created the Table so if anyone has any ideas it would be greatly appreciated
CGSize winSize = [CCDirector sharedDirector].winSize;
CGSize tableSize = CGSizeMake(table_width, table_height);
if (_tableView) {
[_tableView removeFromParentAndCleanup:YES];
[_tableView release];
}
_tableView = [[SWTableView alloc] initWithViewSize:tableSize];
[_tableView setDirection:SWScrollViewDirectionVertical];
[_tableView setVerticalFillOrder:SWTableViewFillTopDown];
[_tableView setDataSource:*my own class*];
[_tableView setDelegate:*my own class*];
[_tableView setPosition:CGPointMake(5, winSize.height/2-130)]; //winSize.height/2 - 160
//refresh table
[_tableView reloadData];
[self addChild:_tableView];
_tableView.isTouchEnabled = YES;
So apparently not a lot of people seems to be using SWTableView, but I know this was a headache for me so I’ll put something here for any future people that have this kind of problem.
I don’t know why this fixes it but create the SWTable like this
This makes it populate in the correct order and from top to bottom, also note I found more issues with SWTable, if the anchor point is not at (0,0) the actual viewable size of the table shrinks, don’t know why. To fix this go into beforeDraw and increase the scaling like so
Finally in retina display, position and size gets messed up too, so just put a if statement to detect if its retina display, and make different position and sizes based on that.