The method presentPreviewAnimated:
returns a BOOL value (YES if it manages to preview and NO for not managing) so you can:
if (![self.docController presentPreviewAnimated:YES])
{
//present openIn
}
Question
I'm putting a UIDocumentInteractionController into my app, which can download arbitrary file types from a server.
It's there for two purposes:
What I'd like to so is to only attempt to display the preview for file types that the system is able to preview. For example, if it's a zip file, the system can't preview that so I want to go straight to the 'Open In'.
I can't find anywhere a list of the types that are supported for preview.
Here's my code:
self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
[self.docController setDelegate:self];
// I'd like to skip this line if the system can't preview the file.
BOOL isOpen = [self.docController presentPreviewAnimated:YES];
if (!isOpen) {
BOOL canOpen = [self.docController presentOpenInMenuFromRect:CGRectMake(300, 300, 100, 100)
inView:self.view
animated:NO];
if (!canOpen) {
// tell user to install an app that's able to open this file.
return;
}
}
Solution
The method presentPreviewAnimated:
returns a BOOL value (YES if it manages to preview and NO for not managing) so you can:
if (![self.docController presentPreviewAnimated:YES])
{
//present openIn
}