简体   繁体   English

打开方式-iOS是否有类似功能?

[英]Open with - is there something similar for iOS?

In Android I can for example open mp4 files in user's apps from my own app (using Intents). 例如,在Android中,我可以通过自己的应用程序(使用Intent)在用户应用程序中打开mp4文件。 In the next example - intent for playing a video: 在下一个示例中-播放视频的意图:

在此处输入图片说明

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(newVideoPath));
intent.setDataAndType(Uri.parse(newVideoPath), "video/mp4");
startActivity(intent);

Is there something similar for iOS? iOS有类似的东西吗? Can I open from my app for example url (of video) in Photos, VLC or another player (which are installed on iPhone/iPad) 我可以从我的应用中打开例如照片,VLC或其他播放器(安装在iPhone / iPad中)的(视频)网址吗

if yes, any example in Swift ? 如果是,在Swift什么例子吗?

You should look at the documentation for Document interaction programming . 您应该查看文档交互编程的文档。

You can register file types that your app supports/can handle and then when a user selects a particular file from the files app or downloads from another app the system will offer a list of apps that can open this file, including yours. 您可以注册应用程序支持/可以处理的文件类型,然后当用户从文件应用程序中选择特定文件或从另一个应用程序下载文件时,系统将提供可以打开此文件的应用程序列表,包括您的文件。

UIActivityViewController might fit your needs. UIActivityViewController可能适合您的需求。

For example, 例如,

let url = // URL to your .mp4 file
let activityVC = UIActivityViewController(activityItems: [url], applicationActivities: nil)
present(activityVC, animated: true, completion: nil)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM