3

I'm trying to add PDF viewing capability to my iPad app using the VFR Reader code.

I can use the existing ReaderViewController to display Reader as a full screen page using code like:

ReaderDocument *document = [ReaderDocument withDocumentFilePath:file password:nil];
if (document != nil)
{
    ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
    // ...
    [self presentModalViewController:readerViewController animated:YES];
}

which works very nicely indeed.

However, I'd like to have other things around the PDF (such as a permanently display bar with buttons on along the top, for example), so ideally I'd like the Reader view inside a view of my own.

I'm rather new to iOS programming and can't figure out how to go about achieving this. Could someone point me in the right direction and tell me what I need to do to have my own view with VFR Reader in a sub-view?

4

1 回答 1

5

我设法弄清楚如何做到这一点。这是任何可能感兴趣的人的解决方案。

我创建了我的容器 ViewController,其 xib 包含一个 UIView 作为 PDF 位置的占位符,然后在其 viewDidLoad 方法中:

// Create the sub-ViewController, the VFR Reader ViewController
ReaderDocument *document = [ReaderDocument withDocumentFilePath:pdfFile password:nil];
_readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];

// Pass on the required delegate for handling the close button
_readerViewController.delegate = self.delegate;

// Add the VFR Reader as a child
[self addChildViewController:_readerViewController];
[self.view addSubview:_readerViewController.view];
// Set the location of the VFR Reader to the same as the placeholder view
_readerViewController.view.frame =  self.pdfPlaceholder.frame; 
[_readerViewController didMoveToParentViewController:self];
于 2014-02-12T14:16:30.563 回答