Issues trying to preview big files with QLPreviewController

寵の児 提交于 2019-12-20 03:29:22

问题


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.

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.

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.

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

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/27860794/issues-trying-to-preview-big-files-with-qlpreviewcontroller

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