[英]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.