Search code examples
iphoneipadpdfxcode4uipageviewcontroller

UIPageViewController - load it with a PDF or Images


i would like to know how can i populate/load the UIPageViewController ( the based project given in xcode 4.2 ) with a PDF file or Images. Could you help ? where should i add some code, what should i add to the project ?

Thanks a lot !


Solution

  • If you want to add PDF you must add a UIWebView on your view and open pdf here

    Update 1 -

    Here is how you can load a local file in UIWebView.

    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"document" ofType:@"pdf"];
    NSURL *targetURL = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
    [webView loadRequest:request];
    
    [self.view addSubview:webView];
    [webView release];