Sharing images from Facebook / Twitter via UIActivityViewController stopped working in iOS 8
I had a great working code for sharing images to FB / Twitter in iOS 7.
- (NSArray *)activityViewController:(NSArray *)activityViewController itemsForActivityType:(NSString *)activityType
{
...
if ([activityType isEqualToString:UIActivityTypePostToFacebook] ||
[activityType isEqualToString:UIActivityTypePostToTwitter])
return @[@"text", [UIImage imageNamed:@"myImage"]];
...
}
After upgrading to iOS 8, I just see a blank image in the posting window and nothing is posted to the social network.
Ideas?
+3
source to share
1 answer
Here's what I did for video sharing. You can try the same for images.
I had video data that I first saved to a file in the documents directory and then I attached that file.
//write to a file [videoData writeToFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.mov"] atomically:YES];
then
- (IBAction)ShareVideoWihFacebook:(id)sender {
//get the file url NSString* path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.mov"];
NSURL *videoURL = [NSURL fileURLWithPath:path];
UIActivityViewController * activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[videoURL,@"Created by ..."] applicationActivities:NULL];
[activityVC setExcludedActivityTypes:@[ UIActivityTypeMail,UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePrint, UIActivityTypePostToWeibo,UIActivityTypeMessage,UIActivityTypeAirDrop,UIActivityTypeSaveToCameraRoll]];
[activityVC setValue:@"My Video" forKey:@"subject"];
[activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
//NSLog(@"completed dialog - activity: %@ - finished flag: %d", activityType, completed);
}];
[self presentViewController:activityVC animated:TRUE completion:nil];
}
0
source to share