Ios 如何在iphone中单独安装的应用程序中打开ppt、excel等文档?
我在xamarin.ios工作。在我的应用程序中,我需要显示一些文档,如ppt、excel等。我想在支持这些文件的设备中单独安装的应用程序中打开这些文件。意味着如果我尝试打开excel文件,那么我可以获取所有支持打开此文件的已安装应用程序的列表,以及我选择的应用程序打开文档Ios 如何在iphone中单独安装的应用程序中打开ppt、excel等文档?,ios,iphone,xamarin,xamarin.ios,Ios,Iphone,Xamarin,Xamarin.ios,我在xamarin.ios工作。在我的应用程序中,我需要显示一些文档,如ppt、excel等。我想在支持这些文件的设备中单独安装的应用程序中打开这些文件。意味着如果我尝试打开excel文件,那么我可以获取所有支持打开此文件的已安装应用程序的列表,以及我选择的应用程序打开文档 如何在xamarin.ios中实现它?试试这个,它会问你想在哪个应用中打开: Device.OpenUri(new Uri("filepath or http url")); 您需要在手机上安装一个可以打开此特殊文件的应用
如何在xamarin.ios中实现它?试试这个,它会问你想在哪个应用中打开:
Device.OpenUri(new Uri("filepath or http url"));
您需要在手机上安装一个可以打开此特殊文件的应用程序
同样的问题也可以在这里找到:您可以尝试使用
UIDocumentInteractionController
:
documentInteraction = new UIDocumentInteractionController();
documentInteraction.Url = new NSUrl(NSBundle.MainBundle.PathForResource("myExcel", "xlsx"), false);
documentInteraction.PresentOptionsMenu(sender.Bounds, sender, true);
确保将此documentInteraction
作为属性保留。您要打开此文件的第三方应用程序必须支持打开方法
此外,您可以使用此控制器在应用程序中预览文件:
// Add a delegate
documentInteraction.Delegate = new MyDocumentDelegate(this);
public class MyDocumentDelegate : UIDocumentInteractionControllerDelegate
{
UIViewController presentedViewController;
public MyDocumentDelegate(UIViewController viewController)
{
presentedViewController = viewController;
}
public override UIViewController ViewControllerForPreview(UIDocumentInteractionController controller)
{
return presentedViewController;
}
}
我想它是以沙马林的形式使用的。我需要xamarin.ios。那我们可以关闭这个帖子吗?它可以帮助其他社区了解如何使用UIDocumentInteractionController。