9

I am using a UIActivityViewController to share info from my app to Twitter and FB, which are properly configured in Settings. The code is the simplest possible:

- (IBAction)share {
    NSString *postText = @"some text";
    UIImage *postImage = [UIImage imageNamed:@"myImage"];
    NSURL *postURL = [NSURL URLWithString:@"myUrl"];
    NSArray *activityItems = @[postText, postImage, postURL];

    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    activityController.excludedActivityTypes =
    @[
      UIActivityTypePrint,
      UIActivityTypeCopyToPasteboard,
      UIActivityTypeAssignToContact,
      UIActivityTypeSaveToCameraRoll,
      UIActivityTypeCopyToPasteboard,
      UIActivityTypeMail,
      UIActivityTypeMessage,
      UIActivityTypePostToWeibo,
      ];
    [activityController setCompletionHandler:^(NSString *activityType, BOOL completed) {
        if ([activityType isEqualToString:UIActivityTypePostToFacebook]) {
            if (completed) [self doSomethingForFB];
        } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {
            if (completed) [self doSomethingForTwitter];
        }
    }];

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

This code works like a charm on the simulator (both iphone and ipad, both ios7 and ios6), but on my device (an iPad with iOS7), when the ActivityViewController shows up, Twitter and FB are there, because the labels are visible, but their icons are missing.

In this answer to a similar question it is claimed that the problem is that the app is an iphone app and the device is an ipad (I can't check this, because my iPhone has iOS 6, which works perfectly). However:

  • why do things work properly on ipad simulator, then?
  • is there any way to show the icons correctly on an ipad with iOS 7 running an iphone app?
2
  • Did you found any answer for the same? Commented Mar 7, 2014 at 7:24
  • 1
    Nope. In fact, I had to submit the app anyway to the store, and the problem persists even on the "live" version (on iPad with iOS7).
    – Maiaux
    Commented Mar 7, 2014 at 13:27

2 Answers 2

1

On iPad you must present the UIActivityViewController in a popover. For iPhone and iPod you must present it modally. UIActivityViewController displays social networks(Facebook & Twitter) icons if you have successfully logged in.

0

I can't actually provide you an answer, but if you can't solve the issue, I can suggest to read how to force the icons customization.
- Topic on stackoverflow: example-of-how-to-customize-uiactivityviewcontroller-share-menu
- Good post: objective-c-custom-uiactivityviewcontroller-icons-text

Hope this helps a little.

1
  • Thanks, I thought of a similar workaround, but it seems that we have to face two problems. 1) custom icons only use the alpha channel (so, no colors in your icons). 2) I don't need to create a new custom action, I simply need to set the icon of a built-in action (Twitter), and this is not described in the posts you linked, and maybe is not possible at all.
    – Maiaux
    Commented Feb 21, 2014 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.