我已经尝试了我能想到的所有方法,但它仍然回答“否”,Apple 也没有任何提示。

- (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;
}

最佳答案

1) 你确信你打开的文件是 kosher 的吗?如果没有,那么返回 NO 将是预期的事情

2)我对你的委托(delegate)方法感到困惑。本方法很高兴自己完成对导航 Controller 的推送。如果您改用此代码,您会更好吗? (有关基本原理,请参阅 docs。)

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
    return [self navigationController];
}

关于iphone - UIDocumentInteractionController presentPreviewAnimated : returning NO and not showing preview,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7366736/

10-12 02:28