2014-02-11 31 views
3

我試圖使用VFR閱讀器代碼將PDF查看功能添加到我的iPad應用程序。在另一個視圖中嵌入VFR閱讀器

我可以使用現有的ReaderViewController顯示Reader作爲使用類似代碼全屏網頁:

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

它非常漂亮,確實有效。

但是,我想要了解PDF的其他內容(例如,頂部帶有按鈕的永久顯示欄),因此理想情況下我希望閱讀器視圖位於我自己的視圖內。

我對iOS編程相當陌生,無法弄清楚如何實現這一點。有人能指出我的方向是否正確,並告訴我在子視圖中我需要做什麼才能在VFR閱讀器中擁有自己的觀點?

回答

5

我設法弄清楚如何做到這一點。這是爲任何可能感興趣的人提供的解決方案。

我創造了我的容器視圖控制器,其包含廈門國際銀行一個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]; 
+0

這個代碼工作正常。應該被接受爲更正的答案。 – Heena

相關問題