CCDirector可能无法响应视图(cocos2d-iphone)

时间:2013-06-13 12:42:10

标签: iphone objective-c uitableview cocos2d-iphone

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** " 

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

2 个答案:

答案 0 :(得分: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];

答案 1 :(得分:0)

你应该使用cocos2d 2.x,因为自2.x以来,CCDirector是UIViewController的子类。