问题
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