Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Sharing in iOS 7

I have seen this format (Image shown below) of share option in most of the iOS applications that support iOS 7. Is there a default code/framework available to implement this share option as it is shown in the image below?

like image 469
Spidy Avatar asked Oct 30 '13 12:10

Spidy


4 Answers

What you are looking for is the UIActivityViewController.

Since you asked a general question I can't do more than give you a link to the documentation

like image 50
Abizern Avatar answered Nov 09 '22 13:11

Abizern


In addition to the accepted answer, a small piece of example code

- (void)shareText:(NSString *)text andImage:(UIImage *)image andUrl:(NSURL *)url
    {
        NSMutableArray *sharingItems = [NSMutableArray new];
        if (text) {
            [sharingItems addObject:text];
        }
        if (image) {
            [sharingItems addObject:image];
        }
        if (url) {
            [sharingItems addObject:url];
        }
        UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
        [self presentViewController:activityController animated:YES completion:nil];
    }

Call shareText, leave the things that you don't want to share at nil.

[self shareText:@"Hello world" andImage:nil andUrl:nil];
like image 29
sjaak bakker Avatar answered Nov 09 '22 14:11

sjaak bakker


The Controller in the image you posted is the UIActivitiyViewController this is a link to the class documentation

like image 4
oiledCode Avatar answered Nov 09 '22 13:11

oiledCode


some good example code: How to display the default iOS 6 share action sheet with available share options?

I know this question is particular to iOS 7, and the code example specifies iOS 6, but AFAICT they are very similar one might find the example code as helpful as I did.

like image 3
GraehamF Avatar answered Nov 09 '22 15:11

GraehamF