Issues trying to preview big files with QLPreviewC

2020-04-16 19:07发布

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条回答
神经病院院长
2楼-- · 2020-04-16 19:50

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.

查看更多
登录 后发表回答