How to Modal or Present a viewController in Cocos2d V3?
cocos2d-iphone, ios, objective-c, uiviewcontroller
Solution
I honestly don't know why this wasn't working for me on other attempts but here is my answer for anyone that also spends 3 days trying to find it -
#import "LoginViewController.h"
-(void)loadMyView{
LoginViewController *myView = [[LoginViewController alloc] init];
[[CCDirector sharedDirector] presentModalViewController:myView animated:YES];
}
Problem
How do I present or modal a viewController from a Cocos2d V3 scene? I am trying to add a Login In ViewController to a game I have created in Cocos2d V3.x that loads from the traditional helloWorldScene but everything I have searched and tried so far hasn't worked. (openGLView, AppController) I had given up and attempted to add a View instead by adding the following two lines - ``` LoginViewController *myView = [[LoginViewController alloc] init]; [[[[CCDirector sharedDirector] view] window] addSubview:myView.view]; ``` This presents the view on top of the scene but setting the anything.delegate = self on anything crashes the App. I assume this is because I am loading a view instead of a viewController which lead to my main question. Any help would be greatly appreciated!