[英]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肯定会批准 ,在这里你可以用两种方式实现
UIWebView的
NSString *pathofFile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:pathofFile]]; [webView loadRequest:request];
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.