我正在尝试在我的应用中显示来自服务器的PDF。
我尝试了文档交互控制器的路线,但只显示应用程序中的文件,而不是在网络上:(
if (URL) {
// Initialize Document Interaction Controller
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
// Configure Document Interaction Controller
[self.documentInteractionController setDelegate:self];
// Preview PDF
[self.documentInteractionController presentPreviewAnimated:YES];
}
UIWebView是否是我从服务器显示PDF的最佳解决方案?不是网站上的PDF,而是服务器上的\ SEVERNAME \ LHSD \ PDFs \ example.pdf
答案 0 :(得分:0)
在objective-c中显示pdf文件的最佳方法是在UIWebView中加载pdf文件。
试试这个:
NSString *stringUrl = @"YOUR-SERVER'S-PDF-FILE-URL";
NSURL *url = [NSURL URLWithString:stringUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
UIWebView *webViewObj = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 300, 450)];
[webViewObj loadRequest:request];
[self.view addSubview:webViewObj];