2011-11-04 92 views
8

我想使用QLPreviewController顯示一個文件。 QL視圖正確顯示(被推到我的導航控制器的頂部),但內容爲空白。但是,不會顯示錯誤,並且應用程序不會崩潰。 檢查文件是否存在返回true。 (證明是,如果我使用[self.docInteractionController presentPreviewAnimated:YES];其中docInteractionController是UIDocumentInteractionController該文件已正確顯示)。在iOS應用程序中的空白QLPreviewController

該代碼直接從Apple示例代碼DocInteraction中獲取。

previewController.dataSource = self; 
previewController.delegate = self; 
// start previewing the document at the current section index 
previewController.currentPreviewItemIndex = 0; //I want the first (and only) document 
[[self navigationController] pushViewController:previewController animated:YES]; 
[previewController release]; 

目前的觀點是QLPreviewControllerDataSource, QLPreviewControllerDelegate,,並委託方法如下:

- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller 
{ 
return self.documentURLs.count; 
} 

- (id)previewController:(QLPreviewController *)previewController previewItemAtIndex: (NSInteger)index 
{ 
return [self.documentURLs objectAtIndex:index]; 
} 

documentURLs是包含文件的fileURLs一個NSArray的。傳遞給UIDocumentInteractionController的fileURL顯示正確。我不一定非要使用QuickLook,我可能只依靠UIDocumentInteractionController,但是它不起作用的事實實在令人煩惱。

預先感謝您

喬瓦尼

+0

18個月後沒有答案。討厭鬼。我有同樣的問題,但只限於某些設備。甚至無法隔離到特定版本的iOS。沒有人能夠隔離這個嗎?它只是QLPreviewController代碼中的一個錯誤? – Axeva

+0

http://stackoverflow.com/questions/16369676/qlpreviewcontroller-crashing-when-tapping-share-button-internal-consistency-nib – quantumpotato

+0

同樣的問題在這裏。我得到了問題「-previewItemViewControllerClassWithStyle:」中的不支持的預覽項目類型時預覽PDF文件本地URL – kemdo

回答

0

作出這樣的demoes問題的樣本。如果您發現它仍然出現在iOS 7上,請提交錯誤報告。

我報告了這個類的錯誤(通過零URL來獲取加載指示器),它在2周內得到修復。

+0

謝謝。我會先嚐試iOS7並最終提交錯誤報告 – maggix

相關問題