1

ArcadeHighScoreLayer.m

我正在尝试使用添加 UITableView

@implementation ArcadeHighScoreLayer
{
    UITableView *table;
    int count[N_OF_SECTION];
}
- (void) onEnterTransitionDidFinish
{
 [[[CCDirector sharedDirector] view] addSubview:table];
}

但是,我收到警告

 "CCDirector may not respond to view"

 and my code through an exception "[CCDirectorDisplayLink view]: unrecognized selector sent to instance 0x7c66c80
    2013-06-13 17:50:08.394 Games[6068:12203] *** Terminating app due to uncaught exception of class '_NSZombie_NSException'
    libc++abi.dylib: terminate called throwing an exception** " 

为什么 ?!如何解决这个错误?!谢谢!

4

2 回答 2

2

在 Cocos2d 2.0 中使用

AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[app.navController.view addSubview:table];

Cocos2d 1.0 然后使用

AppDelegate* app = (AppDelegate*)[UIApplication sharedApplication].delegate;
[app.viewController.view  addSubview:table];
于 2013-06-13T12:55:38.320 回答
0

你应该使用 cocos2d 2.x,因为 CCDirector 从 2.x 开始就是 UIViewController 的子类。

于 2013-06-13T13:03:57.913 回答