I created a game in Xcode and now I decided to add a menu to it, the menu is the first loading view so I changed
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
to:
self.viewController = [[[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil] autorelease];
now the view where my game is, is: ViewController.m and from the menu I go there with:
-(IBAction)gogame:(id)sender {
UIViewController *Game = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:Game animated:YES];}
Because I needed to give the ViewController.m a name I changed in .h and .m:
@interface ViewController to @interface GameViewController in .h
and @implementation ViewController to @implementation GameViewController in .m
Now I made the button in menu “gogame” run it, and when I click the button it goes from the menu to a black screen, it doesn’t crash or anything It only shows the status bar and a black screen. the only issue that xCode gives me is in app delegate: incompatible pointer types assigning to ‘GameViewController *’ from ‘MenuViewController *’.
I do not know why this is not working And I hope someone could exlain me and tell me how to solve this. thanks
UIViewController alone is nothing useful, it’s provided to have behavior added to, so in your method:
Here’s your version of this method:
and it is doing exactly what you are telling it to, present a framework provided UIViewController. You haven’t added any extra behavior or a custom view.
I’m having trouble totally interpreting your current code setup, but it sounds like your new class GameViewController is what you want to show, so change it to:
Based on your renaming/refactoring of the class name, I wasn’t sure what the name of your xib file for the controller is. Is it the original “ViewController” or did you also update that to “GameViewController” (like you should)?
Regarding the warning, where are you creating and assigning a GameViewController?