尝试使用QLPreviewController预览大文件的问题 [英] Issues trying to preview big files with QLPreviewController

查看:97
本文介绍了尝试使用QLPreviewController预览大文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试在iPad应用中预览大文件时遇到问题。在应用程序中,我们使用UIDocumentInteractionController。当我们尝试打开大文件(> 100 MB)时,UIDocumentInteractionController只显示一个灰色屏幕,其中包含文件的名称和大小。

I'm having issues trying to preview big files in my iPad app. In the app we use UIDocumentInteractionController. When we try to open big files (> 100 MB) the UIDocumentInteractionController only shows a grey screen with the name and size of the file.

要缩小我们所做的问题一个简单的应用程序,只尝试使用QLPreviewController预览文件,我们发现同样的问题。

To narrow the problem we have done a simple app that only tries to preview a file using QLPreviewController and we find the same problem.

问题似乎与内存使用情况有关。因为文件的最大尺寸,您可以预览有关iPad型号和后台应用程序数量的更改。

The problem seems related with the memory usage. Because the biggest size of the file you can preview changes regarding the iPad model and the amount of apps in the background.

尝试使用UIWebView预览文件更糟糕:应用程序崩溃(内存警告)。

Trying to preview the files with UIWebView is even worse: the app crashes (memory warning).

如何使用QLPreviewController预览大文件?我应该做些什么特别的事吗?我应该使用其他组件吗?哪一个?

How can I preview big files using QLPreviewController? Should I have to do something special? Should I use another component? Which one?

推荐答案

你可能无法做你想做的事情 - 看来UIDocumentInteractionController只能接受一个URL,而不是一个打开的文件。

You may not be able to do what you want - it appears that UIDocumentInteractionController can only accept a URL, not an open file.

通常,你使用的技巧是使用'映射'文件 - 这是一个不需要完全读入内存的文件,但是根据需要使用虚拟内存,然后释放未使用的块。

Generally, the trick you use is to use a 'mapped' file - this is a file that does not need to be read completely into memory, but using virtual memory is pulled in as needed, then unused chunks freed.

如果你查看此答案您可以看到如何使用NSData对象执行此操作。使用这样的对象,您可以初始化其他类型的数据对象 - 现在还不确定如何处理UIDocumentInteractionController。

If you look at this answer you can see how to do this with a NSData object. With such an object you can initialize other types of data objects - just not sure now what to do about UIDocumentInteractionController.

这篇关于尝试使用QLPreviewController预览大文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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