Hey guys. So I've been wanting to get a UITableView in my game for a while, and was going to rely on that CCTableViewSuite thing, but since the creator hasn't updated his project in a while, I decided to try it myself. Right now, I am creating a view, then adding a UITableView to that view, then adding the first view to my game:
// Create TableView
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 480, 320) style:UITableViewStyleGrouped];
// Set TableView Attributes
tableView.backgroundColor = nil;
tableView.dataSource = self;
tableView.delegate = self;
tableView.opaque = YES;
// Create View
UIView *tableViewWrapper = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)];
// Add TableView to View
[tableViewWrapper addSubview:tableView];
// Add View To Scene
[[[CCDirector sharedDirector] openGLView] addSubview:tableViewWrapper];
This works great, and the framerate is almost always 59-60 FPS. However, the issue I'm having is with selecting rows. Right now, I have implemented the method, didSelectRowAtIndexPath, for detecting touches on certain cells. The problem is, most tutorials I have seen regarding UITableView implement:
test1 *Test1 = [[test1 alloc] initWithNibName:@"test1" bundle:nil];
[self.navigationController pushViewController:Test1 animated:YES];
where you would create an item based on a xib, then push that scene when a certain cell is selected. The problem is in the "self" portion. Cocos2D apparently can't handle navigationController stuff, so doing self.navigationController gives me a warning, along with a crash if I try to run it. I have tried changing
@interface HelloWorldLayer : CCLayer
to
@interface HelloWorldLayer : UIViewController
which doesn't work because then it would break the Cocos2D parts of the class. I have scoured the internet for a solution to this, and while it appears there are a few people in the same boat as me, noone has received a solution, or has shared their solution if they have gotten it. For anyone who wants to look into this, I have posted a zip of my code at:
http://www.filefactory.com/file/cc66624/n/UITableViewTest.zip
If anyone knows anything about this stuff, any help is always appreciated!