iOS - 关闭QLPreviewController时获取文档的URL

时间:2015-03-09 11:43:31

标签: ios presentmodalviewcontroller qlpreviewcontroller presentviewcontroller

我有这个预览PDF文件的代码:

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

现在,当我关闭QLPreviewControllerpreviewController时,会调用此方法:

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

现在,当我调用此方法时,如何返回文档或Pdf的URL:

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

有人可以帮忙吗?

非常感谢。

1 个答案:

答案 0 :(得分:0)

检查文档here。还有另一种方法,它响应用户操作并返回所需的URL:

- (BOOL)previewController:(QLPreviewController *)controller
            shouldOpenURL:(NSURL *)url
           forPreviewItem:(id<QLPreviewItem>)item