谢谢
解决方法 首先,您需要使用NSURL对象表示资源(要打开的下载文件).以下假设一个名为filePath的Nsstring已初始化,其中包含要打开的资源的路径.
NSURL *resourcetoOpen = [NSURL fileURLWithPath:filePath];
然后最好先检查是否有应用程序打开资源.
BOol canopenResource = [[UIApplication sharedApplication] canopenURL:resourcetoOpen];
最后,如果上面的行返回yes,则打开资源.
if (canopenResource) { [[UIApplication sharedApplication] openURL:resourcetoOpen]; }
我引用了UIApplication类引用中关于实例方法canopenURL的以下内容:
This method guarantees that that if openURL: is called,another app will be launched to handle it. It does not guarantee that the full URL is valID.
但是,如果您希望向用户显示已使用适当的UTI注册该文件类型的应用程序列表,您可以执行以下 *** 作 –
UIdocumentInteractionController *documentController = [UIdocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];documentController.delegate = self;[documentController presentopenInMenuFromrect:CGRectZero inVIEw:self.vIEw animated:YES];
您必须实现UIdocumentInteractionControllerDelegate协议.此外,对于已知文件类型,系统应解析UTI属性的正确分配而不进行设置.
总结以上是内存溢出为你收集整理的使用默认应用程序iOS从本地文件系统打开文件全部内容,希望文章能够帮你解决使用默认应用程序iOS从本地文件系统打开文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)