I downloaded file from network, but in advance I don't know what type of file, I name it as PDF file, thus destroying some files, I use QLPreViewController 's method “+ canPreviewItem” judging whether the file can be previewed, in my mind if the pdf file is broken(QLPreViewController actually can’t preview), it will return NO. but it always returns yes, how do I can judge whether the file can be previewed ? Can you give me some help ?
Asked
Active
Viewed 599 times
0
-
Why are you naming a file with a PDF extension even if the file isn't a PDF? – rmaddy Feb 13 '14 at 04:19
-
My server returns three format file to me, but did not return any file information, I can only assume returns are PDF files. – user3304216 Feb 13 '14 at 05:47
-
Wouldn't it be better to fix your server to return a file with the proper extension? – rmaddy Feb 13 '14 at 05:48
-
There is no other option to solve my problem? Now fix the server is not a good choice. – user3304216 Feb 13 '14 at 06:05
-
Inspect the content of the file to determine its type. Update the extension based on that. – rmaddy Feb 13 '14 at 06:06
-
do you have any demo for me, I have no experience about this kind of problem – user3304216 Feb 13 '14 at 06:15
1 Answers
0
+[QLPreviewController canPreviewItem:]
is just telling you, based on the UTI of the item argument, if Quick Look knows how to display this UTI or not.
It is not doing any introspection of the item (which would be very costly).
You can't escape fixing your server to return an appropriate file extension and MIME type, unfortunately.

Thomas Deniau
- 2,488
- 1
- 15
- 15