UIActivityViewController通过文件URL共享时认为我的jpg是视频 [英] UIActivityViewController thinks my jpg is video when share by file URL

查看:106
本文介绍了UIActivityViewController通过文件URL共享时认为我的jpg是视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Documents目录中保存了jpg文件,可以从标准UIActivityViewController共享它们.所有活动项(包括保存图像")均按预期工作,但是,当jpg实际上已保存到相机胶卷中时,轻按保存图像"时,控制台中仍显示以下错误.

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.

这是iOS中的错误,还是我必须以某种方式在文件URL中指定我的文件是jpg(而不是视频)?

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]视频/var/mobile/容器/数据/应用程序/A63DF08E-21D0-435D-A0D7-84D73D632FC9/Documents/ImageStore/805/23.jpg无法保存到已保存的相册中:错误域= AVFoundationErrorDomain代码= -11828无法打开" UserInfo = 0x1702e8b80 {NSLocalizedFailureReason =不支持此媒体格式.,NSLocalizedDescription =无法打开,NSURL =文件:///var/mobile /Containers/Data/Application/A63DF08E-21D0-435D-A0D7-84D73D632FC9/Documents/ImageStore/805/23.jpg,NSUnderlyingError=0x170c4f9f0操作无法完成.(OSStatus错误-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];

推荐答案

在尝试保存png文件时收到了以上消息.还注意到其他一些错误消息.在跟踪这些问题时,通过将OS_ACTIVITY_MODE与disable一起使用来解决了这两个问题,如以下问题/答案所示:

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

这篇关于UIActivityViewController通过文件URL共享时认为我的jpg是视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆