Objective c 如何在SpriteKit中初始化ModalViewController

Objective c 如何在SpriteKit中初始化ModalViewController,objective-c,ios7,sprite-kit,Objective C,Ios7,Sprite Kit,我试图在根视图控制器的顶部显示ModalViewController,如下所示: UIViewController *vc = self.view.window.rootViewController; ModalViewController *modal = [[ModalViewController alloc] init]; [vc presentViewController:modal animated:YES completion:nil]; 在我的ModalViewControlle

我试图在根视图控制器的顶部显示ModalViewController,如下所示:

UIViewController *vc = self.view.window.rootViewController;
ModalViewController *modal = [[ModalViewController alloc] init];
[vc presentViewController:modal animated:YES completion:nil];
在我的ModalViewController中,viewDidLoad定义为:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // Configure the view.
    SKView * skView = (SKView *)self.view;
    skView.showsFPS = YES;
    skView.showsNodeCount = YES;

    // Create and configure the scene.
    SKScene *endGameScene = [[EndGameScene alloc] 
                             initWithSize:skView.bounds.size];
    endGameScene.scaleMode = SKSceneScaleModeAspectFill;

    // Present the scene.
    [skView presentScene:endGameScene];
}
当我运行代码时,出现以下错误:

[UIView setShowsFPS:]: unrecognized selector sent to instance 

似乎skView未被识别为skView。我做错了什么?

我想您的ModalViewController的视图不是SKView。您必须创建一个并将其添加到ModalViewController视图:

SKView * skView = [[SKView alloc]initWithFrame:self.view.frame]; 
[self.view addSubview:skView];