僅限iPad:UIDocumentInteractionController presentPreviewAnimated未被推入導航堆棧和只顯示模態即使當導航控制器被從documentInteractionControllerViewControllerForPreviewiPad上可能的錯誤爲UIDocumentInteractionController:presentPreviewAnimated未被推入導航堆棧
您好返回全部
我想知道是否有人可以幫助我,我相信這可能是一個與iPad相關的錯誤(它適用於iPhone),但在我提交之前需要確認。
要讓UIDocumentInteractionController在導航控制器中工作,我按照推薦的方法返回導航控制器表單documentInteractionControllerViewControllerForPreview,但它不起作用。
我甚至嘗試過蘋果公司提供的UIDocumentInteractionController代碼示例,將其升級到iPad,果然,即使從documentInteractionControllerViewControllerForPreview返回導航控制器,文檔交互控制器也會以模態方式顯示。但是,對於iPhone,它確實被推入導航堆棧。
我試圖設計一個基於splitviewcontroller的應用程序,它使用doc交互控制器讀取PDF文件,這樣PDF將顯示在DetailViewController中,但這隻適用於QLPreviewController(不是Doc交互控制器)。
有沒有人有這個問題?我把下面的示例代碼放在我看到的圖像中:
使用iOS 6.0 SDK的Im。
static NSString* documents2[] =
{
@"PDF Document.pdf"
};
@implementation WhizTBViewController
@synthesize documentURLs, docInteractionController;
#pragma mark -
#pragma mark View Controller
- (void)setupDocumentControllerWithURL:(NSURL *)url
{
if (self.docInteractionController == nil)
{
self.docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docInteractionController.delegate = self;
}
else
{
self.docInteractionController.URL = url;
}
}
- (void)previewDocument {
// three ways to present a preview:
// 1. Don't implement this method and simply attach the canned gestureRecognizers to the cell
//
// 2. Don't use canned gesture recognizers and simply use UIDocumentInteractionController's
// presentPreviewAnimated: to get a preview for the document associated with this cell
//
// 3. Use the QLPreviewController to give the user preview access to the document associated
// with this cell and all the other documents as well.
// for case 2 use this, allowing UIDocumentInteractionController to handle the preview:
NSURL *fileURL;
fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:documents[0] ofType:nil]];
[self setupDocumentControllerWithURL:fileURL];
[self.docInteractionController presentPreviewAnimated:YES];
}
#pragma mark -
#pragma mark UIDocumentInteractionControllerDelegate
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)interactionController
{
return [self navigationController];
}
這是我看到在iPad上
我需要證明它是這樣的(在iPhone上相同的示例代碼)
我創建了一個簡單的示例項目來演示這個問題:https://github.com/kristopherjohnson/DocumentPreviewTest –