I have a project where I use storyboards, a navigation controller, with storyboard segues. I have a cocos2d view in one of the views. The view GameLayer
has the class CCLayer
which is embeded in cocos2dViewController cocos2dViewController : CCViewController
and CCViewController is again the subclass of CCViewController : UIViewController
.So, in my Cocos2d view, which is a CCLayer, can't use the [self performSegue....] method, as it isn't a direct subclass of uiviewcontroller or something.
I tried
GameOverViewController *gameOver = [[GameOverViewController alloc]init];
UIViewController* rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
[rootViewController presentViewController:gameOver animated:YES completion:NULL];
But that just got me Warning: Attempt to present <GameOverViewController: 0x107d0060> on <UINavigationController: 0x9d33890> whose view is not in the window hierarchy!
I also tried
GameOverViewController *gameOver = [[GameOverViewController alloc]init];
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[[app navController] presentModalViewController:gameOver animated:YES];
but that didn't do anything at all
So I either need to perform a selector on one of the higher-up classes which is a subclass of UIViewController, in which case, how do I do that?
Or I need to perform the segue from my CCLayer, in which case how do I do that? Either is fine with me :)
Edit: Clarified question:
I need to do a segue from my GameLayer which is a CCLayer
subclass, and because of this it can't use the normal segue methods. GameLayer is embedded or whatnot in cocos2dViewController
which is a subclass of CCViewController
that finally is a subclass of UIViewController. I use storyboarding in my project, and CCViewController is the view controller that responds to IBOutlets. So I need to push the segue from this file somehow from my Game Layer. You can see the game system here: mediafire.com/?7dil7uolo5k1syr from a template I made. I want to pull a segue out from the game view controller to another view. So far i've tried various methods of doing it in another file, ccdirector and other.
For those not familiar with cocos2d, CCLayer is a subclass of CCNode, which is a subclass of NSObject. So you can see this as a question on how to do a segue in a UIViewController from a NSObject.
So tl;dr: Do a storyboard segue from CCLayer(NSObject) that is embedded in a subclass of a subclass of UIViewController.