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];
}
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With