如何使用UIDocumentInteractionController在另一个应用程序中打开文件?

时间:2022-07-14 19:38:51

I'm having trouble trying to open a file.

我在尝试打开文件时遇到了麻烦。

I download a document file somewhere, and I have a viewer to view the file on my iPhone. I want my app to open the file to the viewer.

我在某处下载了一个文档文件,我有一个查看器可以在我的iPhone上查看该文件。我希望我的应用程序向查看器打开文件。

Here's what I'm trying to do in -(IBAction)buttonPressed:

这是我正在尝试做的事情 - (IBAction)buttonPressed:

dc = [UIDocumentInteractionController interactionControllerWithURL:url];
if([dc presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES])
{
   NSLog(@"menu is presented");
}

When I run the program and click trigger buttonPressed, the NSLog message is printed, and an action sheet appears with two options. One is evernote, the other one is viewer.

当我运行程序并单击触发按钮时,将打印NSLog消息,并显示一个带有两个选项的操作表。一个是evernote,另一个是观众。

However, when I click either option in the action sheet popup, nothing happens.

但是,当我单击操作表弹出窗口中的任一选项时,没有任何反应。

What am I missing? Do I need to implement a delegate method?

我错过了什么?我需要实现委托方法吗?

Please help. Thanks!

请帮忙。谢谢!

1 个解决方案

#1


1  

i've got the answer.

我有答案。

i must retain dc..

我必须保留直流..

fool mistake :(

傻瓜错误:(

#1


1  

i've got the answer.

我有答案。

i must retain dc..

我必须保留直流..

fool mistake :(

傻瓜错误:(