简体   繁体   中英

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

I am adding terms and conditions to my app in a UIWebview. What i really want to know is can i show it as a page by page pdf document or should i use any other method? Will App store accept the pdf format?

Yes, this can be done using UIWebview and surely will get accepted by Apple .

If you are trying to display a PDF file from a web URL , use the below code.

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

Or if you have a PDF file bundled with in your application, use below code.

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

Apple Surely approve , in here you can implement in two ways

  1. UIWebview

     NSString *pathofFile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:pathofFile]]; [webView loadRequest:request]; 
  2. UIDocumentInteractionController preferable for 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]; } 

Sample Tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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