0

I try to share my mp3 songs from my app using UIActivityViewController.It pop the sharing action sheet and attached my file.After share or send it will delete from my app.Why?

It is working good in ios7 but not working well in ios8.

This is my code what I am done.

 UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:
                                             @[@"Here's an attached mp3 File", fileURL] applicationActivities:nil];

            if ([avc respondsToSelector:@selector(popoverPresentationController)])
            {
                // iOS 8+
                UIPopoverPresentationController *presentationController = [avc popoverPresentationController];

                presentationController.sourceView = self.view; 
            }
            [self presentViewController:avc animated:YES completion:nil];

Please help me...

Arunkumar
  • 45
  • 8

1 Answers1

0

It appears that you are not creating your ActivityItems NSArray properly ending with a nil

Try:

NSArray *Items = [NSArray arrayWithObjects:message, image,fileUrl, nil];
UIActivityViewController *activityView = [[UIActivityViewController alloc] initWithActivityItems:Items applicationActivities:nil];

//assuming iOS8+
activityView.popoverPresentationController.sourceView = self.navigationController.navigationBar.viewForBaselineLayout;
//end of assumptions

[self presentViewController:activityView animated:YES completion:nil];

Other than that your code looks good enough

  1. I would only make sure fileUrl is correct
  2. Make sure it actually enters the if statement

Let me know how you do.

Matthew Spencer
  • 2,265
  • 1
  • 23
  • 28