Erik Sapir Erik Sapir - 4 days ago 5
iOS Question

ios8 - how to show the default share sheet

I want to present and use the default "share to other service" sheet in order to allow sharing to twitter, facebook, email, etc.

I can't figure out how to show this view from my app - how can i do that?

Answer

You can use the simple activity controller to show default sharing apps using:

 NSArray *activityItems = [NSArray arrayWithObjects:shareString, shareImage, shareUrl, nil];
 UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
 activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

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

And you can use its completion handler too:

[activityViewController setCompletionHandler:^(NSString *act, BOOL done)
     {
               //Code here
     }];

This will show all default sharing apps.

Comments