It appears I'm only having this bug in iOS 8. I'm trying to share an image and a bit of text with UIActivityViewController
to myself for testing. Sometimes, the shared image results in a question mark on what was supposed to be a shared image, and tapping on it doesn't do anything in the iMessage thread because it's either blank or corrupt. If I go back to my app and try to share again, sometimes the image does get shared perfectly and isn't blank.
Code I'm using (works perfectly in iOS 7):
UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:@[[NSString stringWithFormat:@"Sent from http://appstore.com/appname"],[UIImage imageNamed:@"SomeImage"]]applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeSaveToCameraRoll, UIActivityTypeAddToReadingList, UIActivityTypePostToVimeo, UIActivityTypeAirDrop];
[self presentViewController:activityVC animated:YES completion:NULL];
I'm trying to figure out why this is happening sometimes, and how to fix it. I'd appreciate any help. Attached a screenshot of issue/bug:
Here is a workaround for video file sharing. May be you can try the same for images.
I had video data that I first saved to a file in documents directory and then I attached that file.
//write to a file
[videoData writeToFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.mov"] atomically:YES];
(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];
}
I know this is an old threat, but I recently got into the same kind of situation. First of all, save the file you wanna share, to a temp. directory, and then you wanna share the url, by using url.absoluteUrl
. Doing the absoluteUrl seems very important.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.