Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIDocumentInteractionController presentPreviewAnimated: returning NO and not showing preview

Tags:

ios

iphone

I've tried everything I can think of and it still responds NO and Apple's doesn't have any hints.

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"finished!");

    NSString *tempString = [NSString stringWithFormat:@"file://%@%@", NSTemporaryDirectory(), [[NSProcessInfo processInfo] globallyUniqueString]];
    NSURL *tempURL = [NSURL URLWithString:tempString];
    [receivedData writeToURL:tempURL atomically:YES];

    NSLog(@"tempURL is written!");

    UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:tempURL];
    interactionController.delegate = self;
    [interactionController retain];
    NSLog(@"--- %i", [interactionController presentPreviewAnimated:YES]);
    NSLog(@"presented preview");

    [connection release];
    [receivedData release];
}

- (UIViewController*)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
    NSLog(@"asdf");
    UIViewController *viewController = [[[UIViewController alloc] init] autorelease];
    [self.navigationController pushViewController:viewController animated:YES];
    return viewController;
}
like image 236
Martin Brandenburg Avatar asked Jul 30 '26 09:07

Martin Brandenburg


1 Answers

1) are you confident the document you're opening is kosher? If not, then returning NO would be the thing to expect

2) I'm puzzled by your delegate method. The present method is happy to do the pushing onto the navigation controller all by itself. Do you fair any better if you use this code instead? (See the docs for rationale.)

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
    return [self navigationController];
}
like image 122
Obliquely Avatar answered Jul 31 '26 22:07

Obliquely