我有一个pdf文件,我想打开一个特定的应用程序,如iBooks。我想拥有它,以便用户可以设置他们想要打开它的程序,以及可以处理它的当前安装的程序。下面是我,让我做到这一点的代码,只有用户必须选择每次要使用的应用程序(一个额外的步骤我想避免):iOS - 用特定程序打开文件
NSString *stringVariable = cell.textLabel.text;
NSString *homeDir = NSHomeDirectory();
homeDir = [NSString stringWithFormat: @"%@/%@", homeDir, @"Documents"];
NSString * filePath = [NSString stringWithFormat:@"%@/%@", homeDir, stringVariable];
documentController =
[UIDocumentInteractionController
interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
documentController.delegate = self;
[documentController retain];
documentController.UTI = @"com.adobe.pdf";
[documentController presentOpenInMenuFromRect:CGRectZero
inView:self.view
animated:YES];
所以stringVariable包含的名字有问题的文档,然后显示能够运行它的各种应用程序。如果我可以以某种方式将其填充到某种选择器中,以便用户可以选择要使用的默认应用程序,那就太好了,但是如果我必须自己将它设置为特定的应用程序(如iBooks),那么可以工作太。
我也想知道如何“强制”选择。我想用某些其他应用程序从我的应用程序打开文件 - 但是我不想让用户使用类似'dropbox'的文件打开文件并保存我的文件副本。 – lifeIsGood
目前似乎没有办法。我也环顾四周。 –
我刚才问了Apple Tech的支持,他们已经回复说此刻不可能(刚刚iOS 6发布后) – lifeIsGood