title: How to set view of programatically created view controller to SKView?
body: <p>I am developing a game and would like to have one sprite-kit scene have its own view controller (a conclusion I've reached after much debate), and would like to avoid using storyboard (I can accomplish what I want with storyboard, but would like to learn how to do it without storyboard). </p>
  
  <p>In my main view controller, after clicking a button, I have the following code </p>
  
  <pre><code>MyViewController2 *test = [[MyViewController2 alloc] init]; 
  test.view = [[SKView alloc] init];
  [self presentViewController: test animated:YES completion:nil];
  </code></pre>
  
  <p>However, this just transitions a grey screen with nothing on it (did not overwrite "-(id)init" yet). The following code gets called if I overwrite the "-(id)init" method in MyViewController2:</p>
  
  <pre><code>-(id)init
  {
      NSLog(@"init overwrite works");
      SKView * skView = (SKView *)self.view;
      SKScene2 *scene = [SKScene2 sceneWithSize:skView.bounds.size];
      scene.scaleMode = SKSceneScaleModeFill;
      [skView presentScene:scene];
      return self;
  }
  </code></pre>
  
  <p>but it won't display because I get this error:</p>
  
  <pre><code>-[UIView presentScene:]: unrecognized selector sent to instance 
  </code></pre>
  
  <p>I know what this error means (the presentScene can only be executed by skView and can't be executed by UIView), but even though when I create the ViewController and in its init I set views to be only SKView, I still get this error. How can I fix this? Thanks for your time and help.</p>