Social action sheet (like on iOS 6)
Asked Answered
C

2

31

on iOS 6 a change was that when you want to share something it brings up an action sheet similar to this:

I have seen a few other apps that use this, is there a native way to do this without making a custom action sheet?

Thanks!

Chirr answered 8/11, 2012 at 10:17 Comment(0)
A
79
    NSString *textToShare = @"your text";
    UIImage *imageToShare = [UIImage imageNamed:@"yourImage.png"];
    NSArray *itemsToShare = @[textToShare, imageToShare];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
    activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll]; //or whichever you don't need
    [self presentViewController:activityVC animated:YES completion:nil];

See UIActivityViewController documentation: https://developer.apple.com/documentation/uikit/uiactivityviewcontroller

Ahmedahmedabad answered 8/11, 2012 at 10:34 Comment(1)
Pretty much as is, into whatever method is pertinent to you (i.e. button action, table row selected.) Just substitute 'your text', 'yourImage.png' and whichever activity types you don't want into the excludedActivityTypes line (see documentation link above for full list.) If the user's device isn't able to use a certain activity, it will show or not accordingly. For example, Weibo doesn't show on my device in the U.S. or the Middle East; Twitter won't show if they don't use Twitter on their device, etc.Ahmedahmedabad
H
4

It is actually a custom action sheet that you can easily create as well. In addition to this, you might want to look at this share kit framework.

https://github.com/ShareKit/ShareKit

Hotze answered 8/11, 2012 at 10:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.