Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Probable bug on iPad for UIDocumentInteractionController: presentPreviewAnimated is not pushed into the navigation stack

iPad only: UIDocumentInteractionController presentPreviewAnimated is not pushed into the navigation stack and only shown modally even when a navigation controller is returned from documentInteractionControllerViewControllerForPreview

Hi All

I wonder if anyone could help me here and I believe this could be a bug related to the iPad only (it works on the iPhone) but wanted confirmation before I file this.

To get UIDocumentInteractionController working in a navigation controller, I followed the recommended approach by returning a navigation controller form documentInteractionControllerViewControllerForPreview but it doesnt work.

I even tried the Apple provided UIDocumentInteractionController code sample by upgrading it to iPad and sure enough, the document interaction controller is displayed modally even if I return a navigation controller from documentInteractionControllerViewControllerForPreview. However for the iPhone, it does get pushed into the Navigation stack.

Im trying to design a splitviewcontroller based app that reads PDF files using the doc interaction controller, such that the PDF will display in the DetailViewController, but this only works for QLPreviewController (not the Doc interaction controller).

Has anyone has issues with this? Ive put my sample code below with an image of what I see:

Im using iOS 6.0 SDK.

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];
}

This is what I see on the iPad

This is what I see on the iPad I need to show it up like this (same sample code on the iPhone)

I need to show it up like this (same sample code on the iPhone):

like image 687
qiksand Avatar asked Oct 24 '12 21:10

qiksand


1 Answers

I submitted a bug report to Apple. My report (http://www.openradar.me/radar?id=2785401) was closed as a Duplicate of Bug ID# 12567789. So apparently this is a known issue.

like image 81
Kristopher Johnson Avatar answered Nov 05 '22 10:11

Kristopher Johnson