Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Social action sheet (like on iOS 6)

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!

like image 394
MCKapur Avatar asked Nov 08 '12 10:11

MCKapur


2 Answers

    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

like image 116
j9suvak Avatar answered Oct 09 '22 02:10

j9suvak


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

like image 4
kkocabiyik Avatar answered Oct 09 '22 02:10

kkocabiyik