iphone - UIDocumentInteractionController presentPreviewAnimated : returning NO and not showing preview

标签 iphone ios

我已经尝试了所有我能想到的方法,但它仍然响应“否”,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) 您确信您打开的文件符合犹太洁食标准吗?如果不是,那么返回 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/

相关文章:

iphone - UITextField ResignFirstRespond 在 iPhone 中不起作用?

iphone - 处理 ABPersonViewController 内的点击事件

ios - 如何将 InAppPurchase 设置放入设置包中?

ios - 在 iPhone 上调试 MFI 应用程序

ios - 在 TableView 部分中排序核心数据对象

ios - 将 TableView 添加到 UIViewController 显示 [__NSCFConstantString size] 错误

ios - UIScrollView 中的 UIWebView,如 Apple Mail.app

iphone - 迭代充满日期的 NSArray 并与另一个 NSArray 进行比较

ios - 迁移到惯用的 Swift 2 的 list (也就是 Swift 2 转换指南在哪里)?

ios - RestKit,问题和标签之间的多对多关系,如 Stackoverflow api