Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Custom UIActivityItemProvider share image and text

I'va subclassed UIActivityItemProvider to be able to choose what to share if the user choose Facebook or Twitter or Mail etc. But I can only share text OR image in the function - (id)item, I don't know how to share both text and image for example.

If I read tutorials I know how to do for all share options, but I don't want all share option to have an image or a link or text :

    NSArray* dataToShare = @[someText, [NSURL URLWithString:url], image];
    UIActivityViewController* activityViewController =
    [[UIActivityViewController alloc] initWithActivityItems:dataToShare
                                      applicationActivities:nil];
like image 402
Maelig Avatar asked Oct 30 '14 09:10

Maelig


1 Answers

Found it

CustomActivityItemProvider *itemProvider = [[CustomActivityItemProvider alloc] init];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:@[itemProvider, image]
                                  applicationActivities:nil];

This will use my CustomActivityItemProvider where I choose the text and the image will be used if the share option choosed is compatible (facebook, twitter etc)

like image 148
Maelig Avatar answered Sep 21 '22 07:09

Maelig