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?
Control-click on any file in the Finder, select Share, and click More. You'll see a list of items that you can add and remove from the Share menu. Tick the items that you want to keep in the menu; untick the items you want to remove. Your changes will save automatically.
The Share Sheet is the collection of actions that become available when you tap the Share icon available in most of the common app. For example, if you wanted to send someone a photo from the Photo Library, you would display the photo in the Photos app and tap Share in order to see the send options.
The Share button is easy enough to recognize; it looks like a box with an arrow coming out of it. This button often shows up in the toolbar for apps like Photos and Safari. Tapping the button will grab the photo, video, or web page you're currently viewing and open the Share Sheet for you.
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 when the action performed.
}];
This will show all default sharing apps.
Here is a solution for a "share" popup triggered from a UIBarButtonItem
, that works on both iPhone and iPad:
// "Share" action
- (IBAction)share:(UIBarButtonItem *)sender {
NSString* title = "Content Title";
NSString* link = "http://example.com/content.url";
NSArray* dataToShare = @[title, link];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataToShare
applicationActivities:nil];
// This is key for iOS 8+
activityViewController.popoverPresentationController.barButtonItem = sender;
[self presentViewController:activityViewController
animated:YES
completion:^{}];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With