V.D
V.D

Reputation: 403

CCDirector may not respond to view (cocos2d-iphone)

ArcadeHighScoreLayer.m

I am trying to add UITableView using

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

but,I'm getting warning

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

Why ?! how to resolve this error ?! Thanks!

Upvotes: 1

Views: 544

Answers (2)

Guru
Guru

Reputation: 22042

In Cocos2d 2.0 use

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

Cocos2d 1.0 then use

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

Upvotes: 2

stosha
stosha

Reputation: 2148

You should use cocos2d 2.x, because CCDirector is a subclass of UIViewController since 2.x.

Upvotes: 0

Related Questions