0

I am trying to present a UIActivityViewController within a Sprite Kit scene to share the users high score. I am using a SKSpriteNode as a button.

My code:



    MyScene.h

    @property (nonatomic, weak) ViewController * spriteViewController;

    ViewController.m

    // within viewDidLoad method
    MyScene * myScene = [[MyScene alloc] init];
    myScene.spriteViewController = self;

    MyScene.m

    // within touchesDidBegin method
    if ([_shareButton containsPoint:touchLocation]) {

    NSString * textToShare = [NSString stringWithFormat:@"I just... blah", [GameData sharedGameData].highScore];
    NSArray * items = @[textToShare];
    UIActivityViewController * activityVC = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
    activityVC.excludedActivityTypes = @[UIActivityTypeAddToReadingList, ...];
    [self.spriteViewController presentViewController:activityVC animated:YES completion:nil];

Please disregard any typos as I quickly typed that out as my code is on another computer.

The above code does nothing. I assume that it is displaying the UIAVC on the VC but not on top of the scene, but I am probably wrong. Am I going about this completely wrong? I can't seem to find help in the Apple Documentation nor google.

Your guidance is greatly appreciated.

djames04
  • 11
  • 2

1 Answers1

0

I was going about this all wrong and was tired and frustrated. I had tried to use a delegate, but was implementing it wrong.

I found the answer here: https://stackoverflow.com/a/20072795/3624943

Community
  • 1
  • 1
djames04
  • 11
  • 2