我需要从API下载文件一样.PPT,.doc或.ppt文件显示在iOS应用
http://52.76.226.179/aapc-social-web/sites/default/files/media_docs/2009/content-601938936.ppt
,并在我的iOS应用程序显示一个预览。
请帮忙。
我需要从API下载文件一样.PPT,.doc或.ppt文件显示在iOS应用
http://52.76.226.179/aapc-social-web/sites/default/files/media_docs/2009/content-601938936.ppt
,并在我的iOS应用程序显示一个预览。
请帮忙。
[UIDocumentInteractionController][1]
是你在找什么。
主要区别方面QLPreviewController
是它可以显示预览,也可以显示一个UiActionSheet
或弹出窗口,显示与该格式兼容的应用程序并将文档的显示委托给它们。
使用它非常容易。检查here
。
我已经使用过它。 NSString * filePath = [[NSBundle mainBundle] pathForResource:@“content-601938936”ofType:@“ppt”]; UIDocumentInteractionController * documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]]; //配置文档交互控制器 [documentInteractionController setDelegate:self]; [documentInteractionController presentPreviewAnimated:YES]; 但显示我的文件,如http://i.stack.imgur.com/fxQe3.jpg 请建议。 –
我认为这发生在文件不兼容预览时,你确定路径是否正确? – Andrea
我认为你是对的文件有问题。我试着用另一个像魅力一样工作的文件。感谢帮助。 –
进口此PKG
#import <QuickLook/QuickLook.h>
使用此代码视图控制器。
QLPreviewController *previewController=[[QLPreviewController alloc]init];
previewController.delegate=self;
previewController.dataSource=self;
previewController.view.frame = self.conditionsofUseView.bounds;
[self.conditionsofUseView addSubview:previewController.view];
[self addChildViewController:previewController];
[previewController didMoveToParentViewController:self];
[previewController.navigationItem setRightBarButtonItem:nil];
添加这些代表methodes
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
return 1;
}
- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"docFileName" ofType:@"file type"]; //doc,ppt,pdf etc
return [NSURL fileURLWithPath:filePath];
}
如果你只是想查看Office文件,看看:
快速查找框架支持大量的文件格式,你可以在上面的链接查看。它在iOS 4.0及更高版本中可用。
您还可以使用UIWebView来显示它们。请参阅Using UIWebView to display select document types。
这可能会帮助您:https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/QLPreviewController_Class/index.html#//apple_ref/occ/cl/QLPreviewController –
请分享您的代码 – SM18
的NSString * filePath = [[NSBundle mainBundle] pathForResource:@“content-601938936”ofType:@“ppt”]; UIDocumentInteractionController * documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]]; //配置文档交互控制器 [documentInteractionController setDelegate:self]; [documentInteractionController presentPreviewAnimated:YES]; –