user3449878
user3449878

Reputation: 87

Finds no presentViewController

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];
    }

Upvotes: 6

Views: 2057

Answers (1)

Woodstock
Woodstock

Reputation: 22926

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];

Upvotes: 3

Related Questions