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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With