如何在iOS UIWebView中显示带有PDF内容的NSData? [英] How to display NSData with PDF content in iOS UIWebView?

查看:117
本文介绍了如何在iOS UIWebView中显示带有PDF内容的NSData?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过 UIWebView 在我的iPad应用程序中显示PDF,如下所示。

I am trying to show a PDF in my iPad application through UIWebView as shown below.

NSData * responseData = [NSURLConnection sendSynchronousRequest:mutableUrlRequest returningResponse:nil error:nil];
[pdfWebView loadData:responseData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil]; 

但这不起作用。这是一种正确的展示方式吗?如果没有,任何人都可以指导我在UIWebView中显示PDF或任何其他有用的方法。

But this doesn't work. Is it a right way to display? If not could anyone guide me in showing the PDF in UIWebView or any other useful method.

谢谢!

推荐答案

得到了我的问题的答案。以下行将完成魔术。

Got the answer for my question. The below line will do the magic.

 [webview loadData:PdfContent MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];

这篇关于如何在iOS UIWebView中显示带有PDF内容的NSData?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆