How to present UIAlertController from SKScene

后端 未结 3 1914
鱼传尺愫
鱼传尺愫 2021-01-22 23:01

I\'m working in Spritekit and I\'m trying to present a UIAlertController from my SKScene, but I am having trouble doing it. I\'ve watched several tutorials but none of the UIAle

3条回答
  •  悲&欢浪女
    2021-01-22 23:38

    Just set a pointer to your viewController when you create your scene. Then you can call it like this: [self.viewController presentViewController:alert animated:YES completion:nil];

    In your ViewController:

    // Create and configure the scene.
    GameScene *scene = [GameScene sceneWithSize:viewSize];
    SKView * skView = (SKView *)self.view;
    scene.viewController = self;
    
    // Present the scene.
    [skView presentScene:scene];
    

提交回复
热议问题