Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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];
    }
like image 744
user3449878 Avatar asked Mar 22 '14 14:03

user3449878


1 Answers

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];
like image 181
Woodstock Avatar answered Oct 18 '22 14:10

Woodstock