Finds no presentViewController

objective-c, xcode5

Solution

The SKScene class doesn't implement presentViewController. You can only call this on a UIViewController subclass.

You need to get a reference to your containing view controller.

You can use "presentModalViewController" by using this code to access the root view controller

UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: activityViewController animated: YES completion:nil];

Problem

As I write this in ViewController.m all well, but when I write it in a MyScene class, I get the error: No visible @interface for 'MyScene' declares the selector 'presentViewController:animated:completion:' ``` if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [tweetSheet setInitialText:@"text"]; [self presentViewController:tweetSheet animated:YES completion:nil]; } ```

Original source