UIActivityViewController optional / different Content for different ActivityTypes

221 views Asked by At

I have to integrate native share options into my project.

This is the code so far :

- (IBAction)shareButtonClicked:(id)sender
{

    NSString *text = @"This is the share text";
    NSString *url = [NSString stringWithFormat:@"http://share.me/"];
    UIImage *image = [UIImage imageNamed:@"icon"];

    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[text,url,image] applicationActivities:nil];

    [activityVC setValue:@"Share Subject" forKey:@"subject"];


    NSArray *excludeActivities = @[UIActivityTypeAirDrop,
                                   UIActivityTypePrint,
                                   UIActivityTypeAssignToContact,
                                   UIActivityTypeSaveToCameraRoll,
                                   UIActivityTypeAddToReadingList,
                                   UIActivityTypePostToFlickr,
                                   UIActivityTypePostToVimeo];

    activityVC.excludedActivityTypes = excludeActivities;

    [self presentViewController:activityVC animated:YES completion:nil];
}

It works fine but i do have a problem. I dont want the image in the ActivityType Message and Facebook Messenger.

This seems to be useful : http://www.albertopasca.it/whiletrue/2012/10/objective-c-custom-uiactivityviewcontroller-icons-text/

But I don't want different Text for my activities. I just want to "deactivate" the image for specific Activities.

Is there an easier way to do the job than to subclass UIActivity ? Like here : iOS 6 - UIActivityViewController items

Something like :

if(userClickedActivity == UIActivityTypePostToMessage){
    self.setimage = nil;
}

Thank you so far !

0

There are 0 answers