2016-02-17 26 views

回答

3

是的,這可以使用UIWebview完成,當然將被Apple接受。

如果您嘗試從網址顯示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]; 
+0

感謝您的幫助 –

2

蘋果當然批准,在這裏你可以用兩種方式

  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]; 
    } 
    

樣品Tutorial

+0

如果您需要任何其他幫助 –

+0

感謝這對我們非常有幫助 –

相關問題