I am using Cocos2D for my main framework. In some cases, I want Cocos2D to load a nib file and have that be the view:
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
TargetPlayerViewController *myController = [[TargetPlayerViewController alloc]initWithNibName:@"TargetPlayerViewController" bundle:nil];
[window addSubview:[myController view]];
[window makeKeyAndVisible];
This works as expected, and shows the TargetPlayerViewController
. Wonderful!
What I need to know is: once that view has been loaded, how can I have the view remove itself? I've tried a few different ways, but all of them result in the program crashing.
To test I have a button on the view set up which triggers this method:
- (IBAction)GTFOnow:(id)sender {
NSLog(@"GFTO");
//window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//[self.view removeFromSuperview];
//[window makeKeyAndVisible];
}
GTFOnow is a method in TargetPlayerViewController. When it is called, the current subview (that was called in the Cocos2D code above) should be removed from the window.