1

I'd like to provide different content to the different services in a UIActivityIndicatorView. For example, an HTML string for email, standard string for Facebook/Twitter, and an image for Copy. All of this happens within a single popover window.

I don't think this is possible. As I was playing around with all of the involved classes, I notices that the services that appear in the activity view change as the content type I provided it changed. In other words, when I provided a string, set A of services appeared. When I provided an image, set B of services appeared.

Next I tried adding both string and image thinking that possibly it would provide different content, however this just adds both the string and image to the services (for example an email is created with a string, then the image below).

Here is how I am providing string values (which are html links):

-(void)shareButtonTouchUpInside:(SMActionToolbarViewController*)sender{
    // Reposition anchor view for UIPopoverController to point at
    [self repositionAnchorViewToButtonFrame:self.actionToolbarViewController.shareButtonFrame];

    // Asynch download of image
    [SMUtility downloadAsset:self.selectedAsset completion:^(UIImage *image) {
        // Create image source
        SMActivitySource *activityImageSource = [[SMActivitySource alloc]initWithImage:image];
        // Create string source
        NSString *assetsString = [SMUtility assetsString:[NSArray arrayWithObject:self.selectedAsset]];
        SMActivitySource *activityStringSource = [[SMActivitySource alloc]initWithString:assetsString];

        // Present UIActiviyViewController within an UIPopoverController
        NSArray *items = [@[activityImageSource, activityStringSource]mutableCopy];
        UIActivityViewController *activityViewController = [[UIActivityViewController alloc]initWithActivityItems:items applicationActivities:nil];
        [activityViewController setCompletionHandler:^(NSString *activityType, BOOL completed){
            // TODO: Populate mixpanel data
            [SMMixPanel eventSharePhotoMethod:@"Unknown"];
        }];
        self.buttonPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
        [self.buttonPopoverController presentPopoverFromRect:self.anchorView.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }];
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
VaporwareWolf
  • 10,143
  • 10
  • 54
  • 80
  • possible duplicate of [Different data for sharing providers in UIActivityViewController](http://stackoverflow.com/questions/13551042/different-data-for-sharing-providers-in-uiactivityviewcontroller) – rmaddy May 15 '13 at 18:10

2 Answers2

3

You should subclass UIActivityItemProvider or create objects that conform to UIActivityItemSource. Pass in an array of those (one for each thing you want to share), and have some of them return nil depending on the chosen activity in the activityViewController:itemForActivityType: call.

ccjensen
  • 4,578
  • 2
  • 23
  • 25
0

This Question has been asked time and time again, the only way to fix it is to make your own UIActivity, see apple documentation on how to do that. Here is a link: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIActivity_Class/Reference/Reference.html

virindh
  • 3,775
  • 3
  • 24
  • 49