Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying a PDF with UIWebView Not Working
    primarykey
    data
    text
    <p>So, I realize that there have been many questions regarding using a UIWebView to display a PDF in an app (on the iPad). I have reviewed everything I can find but I can't seem to find any satisfaction.</p> <p>What I'm trying to do is very basic so I really don't know why it's not working. All I need to do is display a locally stored PDF in the UIWebView. Essentially, all I'm getting is a black screen. If someone could take a look at my code, I'd really appreciate it. Thanks.</p> <pre><code> - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Segue to the materials screen. if ([segue.identifier isEqualToString:@"materials"]) { PDFViewController *pdfViewController = [segue destinationViewController]; NSIndexPath *path = [self.tableView indexPathForSelectedRow]; int row = [path row]; Lesson *selected = [purchasedLessons objectAtIndex:row]; pdfViewController.selectedLesson = selected ; //Start Load PDF in UIWebView pdfViewController.pdfWindowTitle.title = selected.titleAndSubtitle; pdfViewController.pdfWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 1024, 704)]; NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"moonlightSonataFirstMovement" ofType:@"pdf"]; NSURL *url = [NSURL fileURLWithPath:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [pdfViewController.pdfWebView loadRequest:requestObj]; //End Load PDF } } </code></pre> <p>I've checked to see if my object is bring passed into the scene properly (and it is) and if I am getting a proper request out; i'm getting: </p> <p><code>&lt;NSURLRequest file://localhost/Users/MYCOMPUTER/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/AB161E57-D942-44C2-AA75-030087820BED/iLessons%20Piano.app/moonlightSonataFirstMovement.pdf&gt;</code></p> <p>Also, I've have this error message:</p> <pre><code>iLessons Piano[23080:f803] DiskImageCache: Could not resolve the absolute path of the old directory. </code></pre> <p>Additionally, the NSLog message gets printed out 8 times for some reason.</p> <p>The only thing I can think of is that I need to do this loading when I call my prepareForSegue function in the previous scene. That or use a different method like Quartz. But I'd rather use a UIWebView since all I really need to do is display and allow scrolling.</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.
 

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