Erik Sapir Erik Sapir - 7 months ago 52
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?


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.