Search code examples
iosobjective-cuiwebviewuipopovercontrolleruiwebviewdelegate

PDF in UIWebView not working


I have two UIPopoverController. each one opens up a pdf in a UIWebViewDelegate when I click the respective buttons. However,only one works. Both buttons, A and B, have this format for the click function (except Button B would say ButtonB not ButtonA)

- (IBAction)openPDF_Pictures_A:(id)sender
{


    ButtonAPDFViewController *DWV =[[ButtonAPDFViewController alloc] initWithNibName:nil bundle:nil];

    self.masterPopOverController = [[UIPopoverController alloc] initWithContentViewController:DWV];

    [self.masterPopOverController presentPopoverFromRect:[sender frame] inView:[sender superview] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    [self.masterPopOverController setPopoverContentSize:CGSizeMake(600, 800) animated:NO];




}

And in the UIViewController for each UIWebView, is this:

#import "ButtonAViewController.h"

@interface ButtonAViewController ()

@end

@implementation ButtonAViewController

@synthesize buttonAPDFView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];


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



}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

Both buttons A and B are on the same view. I did make one of the IBActions use masterPopOverController2 and one of the masterPopOverController to see if that would resolve anything but it doesn't. The one that doesn't work opens up a popover but it doesn't show the PDF in the popover. Any suggestions?


Solution

  • just realized I didn't add the UIWebView inside the UIView in the xib...