iOS - get document's URL when QLPreviewControl

2019-08-09 17:42发布

I have this code which previews the PDF file:

QLPreviewController *previewController=[[QLPreviewController alloc]init];
previewController.delegate=self;
previewController.dataSource=self;
[self presentModalViewController:previewController animated:YES];

Now, when I close QLPreviewController or previewController this method is called:

- (void)previewControllerDidDismiss:(QLPreviewController *)controller {
    NSLog(@"You closed the document");
}

Now, how I can return the document's or Pdf's URL when I call this method:

- (void)previewControllerDidDismiss:(QLPreviewController *)controller {
        //here I need to be able to get the PDF's URL or Data when is closed
    }

Can anyone please help?

Many thanks.

1条回答
We Are One
2楼-- · 2019-08-09 18:38

Check documentation here. There is another method, that responds to user actions and returns needed URL:

- (BOOL)previewController:(QLPreviewController *)controller
            shouldOpenURL:(NSURL *)url
           forPreviewItem:(id<QLPreviewItem>)item
查看更多
登录 后发表回答