Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何使用;“在……中打开”;iOS应用程序的功能?_Iphone_Ios_Ipad - Fatal编程技术网

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
可能会出现问题。检查