iOS - get document's URL when QLPreviewController is closed

旧时模样 提交于 2019-12-24 14:12:43

问题


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:


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


来源:https://stackoverflow.com/questions/28941178/ios-get-documents-url-when-qlpreviewcontroller-is-closed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!