我想使用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,但是它不起作用的事實實在令人煩惱。
預先感謝您
喬瓦尼
18個月後沒有答案。討厭鬼。我有同樣的問題,但只限於某些設備。甚至無法隔離到特定版本的iOS。沒有人能夠隔離這個嗎?它只是QLPreviewController代碼中的一個錯誤? – Axeva
http://stackoverflow.com/questions/16369676/qlpreviewcontroller-crashing-when-tapping-share-button-internal-consistency-nib – quantumpotato
同樣的問題在這裏。我得到了問題「-previewItemViewControllerClassWithStyle:」中的不支持的預覽項目類型時預覽PDF文件本地URL – kemdo