UIActivityViewController thinks my jpg is video when share by file URL

江枫思渺然 提交于 2019-12-06 17:35:11

问题


I have jpg files saved in the Documents directory that can be shared from a standard UIActivityViewController. All activity items (including Save Image) work as expected, but when Save Image is tapped, the following error shows in the console, despite the fact that the jpg does actually get saved to the camera roll.

Is this a bug in iOS, or do I have to somehow specify that my file is a jpg (and not a video) in the file URL?

2015-07-29 06:46:58.317 AppName[4658:893408] Video /var/mobile/Containers/Data/Application/A63DF08E-21D0-435D-A0D7-84D73D632FC9/Documents/ImageStore/805/23.jpg cannot be saved to the saved photos album: Error Domain=AVFoundationErrorDomain Code=-11828 "Cannot Open" UserInfo=0x1702e8b80 {NSLocalizedFailureReason=This media format is not supported., NSLocalizedDescription=Cannot Open, NSURL=file:///var/mobile/Containers/Data/Application/A63DF08E-21D0-435D-A0D7-84D73D632FC9/Documents/ImageStore/805/23.jpg, NSUnderlyingError=0x170c4f9f0 "The operation couldn’t be completed. (OSStatus error -12847.)"}

Here's the code I'm using:

NSURL *fileURL = [NSURL fileURLWithPath: [...path to my file...] isDirectory:NO];
UIActivityViewController *activityViewController = [[UIActivityViewController    alloc] initWithActivityItems:@[fileURL] applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard, UIActivityTypePrint, UIActivityTypeAssignToContact, UIActivityTypeAddToReadingList, UIActivityTypePostToVimeo];
[self presentViewController:activityViewController animated:YES completion:nil];

回答1:


I got the above message when trying to save a png file. Also noticed some other error messages. In tracking those down, got rid of both problems by applying the OS_ACTIVITY_MODE with disable as seen in following question/answer: "Reading from public effective user settings" in iOS 10



来源:https://stackoverflow.com/questions/31705767/uiactivityviewcontroller-thinks-my-jpg-is-video-when-share-by-file-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!