Iphone UIDocumentInteractionController PresentPreviewInimated:返回否但不显示预览
我已经尝试了我能想到的一切,但它仍然没有回应,苹果也没有任何提示Iphone UIDocumentInteractionController PresentPreviewInimated:返回否但不显示预览,iphone,ios,Iphone,Ios,我已经尝试了我能想到的一切,但它仍然没有回应,苹果也没有任何提示 - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"finished!"); NSString *tempString = [NSString stringWithFormat:@"file://%@%@", NSTemporaryDirectory(), [[NSProcessInfo processInfo] g
- (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) 我对你的委托方式感到困惑。目前的方法很乐意自己推到导航控制器上。如果改用此代码,您是否会更公平?(有关基本原理,请参见。)
我在PresentPreviewEnimated上也遇到了类似的问题,返回了NO。在我的例子中,我丢失了文件的扩展名。当我将文件从document重命名为document.xlsx时,它已成功打开。1)我使用的是PDF和HTMl文件。2) 我以前试过,但没有得到更好的结果。我更改了它,但仍然得到0。是否检查了tempUrl是否为null?
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
return [self navigationController];
}