Social action sheet (like on iOS 6)

MCKapur picture MCKapur · Nov 8, 2012 · Viewed 20.6k times · Source

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!

Answer

j9suvak picture j9suvak · Nov 8, 2012
    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