1

i want to add Airdrop sharing to my spritekit game

It dosent work using this code:

UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil]
Ben
  • 1,906
  • 10
  • 31
  • 47

1 Answers1

0

I am thinking the issue is where you have the code you posted. You possibly have it in viewDidLoad of your UIViewController.

Do this in your UIViewController :

-(void)viewDidAppear:(BOOL)animated
{
   // assuming you are creating objectsToShare here or before this point

    UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
    [self presentViewController:controller animated:YES completion:nil]

}

I believe the issue is that the view is not fully configured when you are trying to add your UIActivityViewController.

I believe that the bounds and some other properties of the view are not yet properly configured in the viewDidLoad method, which results in a failure to display it.

prototypical
  • 6,731
  • 3
  • 24
  • 34