Iphone 如何使用;“在……中打开”;iOS应用程序的功能?
我不是想把我的应用程序添加到“打开中…”列表中,而是想获取列表本身。并将文件发送到另一个应用程序 我正在开发内部通信应用程序,所以当用户收到文件附件时,他/她可以使用每个设备上安装的任何应用程序打开文件Iphone 如何使用;“在……中打开”;iOS应用程序的功能?,iphone,ios,ipad,Iphone,Ios,Ipad,我不是想把我的应用程序添加到“打开中…”列表中,而是想获取列表本身。并将文件发送到另一个应用程序 我正在开发内部通信应用程序,所以当用户收到文件附件时,他/她可以使用每个设备上安装的任何应用程序打开文件 UIDocumentInteractionController *controller = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:appFile]];
UIDocumentInteractionController *controller = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:appFile]];
self.controller.delegate = self;
CGRect navRect = self.view.frame;
[self.controller presentOptionsMenuFromRect:navRect inView:self.view animated:YES];
实施以下UIDocumentInteractionControllerDelegate
方法
#pragma mark - UIDocumentInteractionControllerDelegate
//===================================================================
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
return self.view;
}
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
return self.view.frame;
}
查看UIDocumentInteractionController,这里是另一个选项: 使用
iOS 6.0>
版本中提供的UIActivityViewController
//create instance with file URL
UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:@[fileURLHere] applicationActivities:nil];
//present it
[self presentViewController:activity animated:YES completion:NULL];
注意:使用UIDocumentInteractionController
可能会出现问题。检查