Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, this can be done with the UIWebView.</p> <p>If you are trying to display a PDF file residing on a server somewhere, you can simply load it in your web view directly:</p> <p><strong>Objective-C</strong></p> <pre><code>UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)]; NSURL *targetURL = [NSURL URLWithString:@"https://www.example.com/document.pdf"]; NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; [webView loadRequest:request]; [self.view addSubview:webView]; </code></pre> <p><strong>Swift</strong></p> <pre><code>let webView = UIWebView(frame: CGRect(x: 10, y: 10, width: 200, height: 200)) let targetURL = NSURL(string: "https://www.example.com/document.pdf")! // This value is force-unwrapped for the sake of a compact example, do not do this in your code let request = NSURLRequest(URL: targetURL) webView.loadRequest(request) view.addSubview(webView) </code></pre> <p>Or if you have a PDF file bundled with your application (in this example named "document.pdf"):</p> <p><strong>Objective-C</strong></p> <pre><code>UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)]; NSURL *targetURL = [[NSBundle mainBundle] URLForResource:@"document" withExtension:@"pdf"]; NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; [webView loadRequest:request]; [self.view addSubview:webView]; </code></pre> <p><strong>Swift</strong></p> <pre><code>let webView = UIWebView(frame: CGRect(x: 10, y: 10, width: 200, height: 200)) let targetURL = NSBundle.mainBundle().URLForResource("document", withExtension: "pdf")! // This value is force-unwrapped for the sake of a compact example, do not do this in your code let request = NSURLRequest(URL: targetURL) webView.loadRequest(request) view.addSubview(webView) </code></pre> <p>You can find more information here: <a href="http://developer.apple.com/iphone/library/qa/qa2008/qa1630.html" rel="noreferrer" title="Technical Q&amp;A QA1630: Using UIWebView to display select document types">Technical QA1630: Using UIWebView to display select document types</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload