繁体   English   中英

我们可以在IOS应用的UIWebview中将条款和条件作为PDF加载吗?

[英]Can we load the terms and conditions as a PDF in a UIWebview for IOS apps?

我在UIWebview中向我的应用添加了条款和条件。 我真正想知道的是,我可以将其作为页面pdf文档显示,还是应该使用任何其他方法? App商店会接受pdf格式吗?

是的,这可以使用UIWebview完成,肯定会被Apple接受

如果您尝试从Web URL显示PDF文件,请使用以下代码。

NSURL *targetURL = [NSURL URLWithString:@"http://yourdomain.com/file_toopen.pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];

或者,如果您的应用程序中捆绑了PDF文件,请使用以下代码。

NSString *path = [[NSBundle mainBundle] pathForResource:@"filetoopen" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];

Apple肯定会批准 ,在这里你可以用两种方式实现

  1. UIWebView的

     NSString *pathofFile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:pathofFile]]; [webView loadRequest:request]; 
  2. UIDocumentInteractionController最适合PDF

     NSURL *URL = [[NSBundle mainBundle] URLForResource:@"sample" withExtension:@"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]; } 

示例教程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM