Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter icon not showing in UIActivityViewController in iOS 7 on the device

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?
like image 511
Maiaux Avatar asked Feb 20 '14 23:02

Maiaux


1 Answers

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.

like image 187
Santhosh Avatar answered Oct 12 '22 12:10

Santhosh