2016-09-20 9 views
0

webviewにMSOffice拡張機能を表示したい。これは可能ですか?
私はこれ試してみた:iosのUIWebviewにpptファイルを表示する

NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]]; 

NSString *filePath = [resourceDocPath 
         stringByAppendingPathComponent:@"myPDF.pdf"]; 
[pdfData writeToFile:filePath atomically:YES]; 

CGRect rect = [[UIScreen mainScreen] bounds]; 
CGSize screenSize = rect.size; 
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,screenSize.width,screenSize.height)]; 



// Now create Request for the file that was saved in your documents folder 
//UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 250, self.view.frame.size.width, 300)]; 

NSURL *targetURL = [NSURL URLWithString:fileurl]; 
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; 
[webView loadRequest:request]; 

[self.view addSubview:webView]; 

をしかし、私はメッセージを取得:

"文書の読み取り中にエラーが発生しました"。

+0

の下に使用し、その後、プロジェクトに

[webView loadRequest:[NSURLRequest requestWithURL: [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"FileName" ofType:@"ppt"]isDirectory:NO]]]; 

を落とし以下試してみてくださいmyPDF.pdf "私はあなたがpptを表示したいと思いますか? –

+0

どこにpptファイルを置いていますか?プロジェクト内か、サーバーからダウンロードしますか? –

+0

"fileurl"でどのように価値が得られますか? – kb920

答えて

0

あなたpptファイルがドラッグである場合は、NSDataの形でサーバーからファイルを取得している場合はu」は使用した理由

NSURL *url=[NSURL URLWithString:[@"yourURL" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 
NSData* responseData = [NSData dataWithContentsOfURL: url]; 

[webView loadData:responseData MIMEType:@"application/ppt" 
textEncodingName:@"utf-8" baseURL:[NSURL URLWithString:@""]]; 
+0

私はresponseData ... @ ajay_nasaの代わりに何を使用すべきですか?同じエラーが発生しています。ドキュメントを読み込んでいるときにエラーが発生しました。 –

+0

[webView loadData:filename MIMEType:@ "application/ppt" textEncodingName:@ "utf- 8 "baseURL:[NSURL URLWithString:fileurl]]; [self.view addSubview:webView]; –

+0

pptファイルはどこに置いていますか? –

関連する問題