我在 Xcode 中创建了一个游戏,现在我决定给它添加一个菜单,菜单是第一个加载视图,所以我改变了
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
到:
self.viewController = [[[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil] autorelease];
现在我的游戏所在的视图是: ViewController.m 并从我去那里的菜单中:
-(IBAction)gogame:(id)sender {
UIViewController *Game = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:Game animated:YES];}
因为我需要给我在 .h 和 .m 中更改的 ViewController.ma 名称:
@interface ViewController 到 .h 中的 @interface GameViewController
和@implementation ViewController 到.m 中的@implementation GameViewController
现在我让菜单“gogame”中的按钮运行它,当我单击该按钮时,它从菜单进入黑屏,它不会崩溃或任何东西它只显示状态栏和黑屏。xCode 给我的唯一问题是应用程序委托:从“MenuViewController *”分配给“GameViewController *”的指针类型不兼容。
我不知道为什么这不起作用我希望有人可以解释我并告诉我如何解决这个问题。谢谢