Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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
Ios 如何以编程方式打开带有myapp文件夹的默认文件应用程序?_Ios_Swift_Directory_Swiftui - Fatal编程技术网

Ios 如何以编程方式打开带有myapp文件夹的默认文件应用程序?

Ios 如何以编程方式打开带有myapp文件夹的默认文件应用程序?,ios,swift,directory,swiftui,Ios,Swift,Directory,Swiftui,我的应用程序中有包含文件的文件夹。如何以编程方式打开带有myapp文件夹的默认文件应用程序 这是文件中GarageBand应用程序的类似文件夹 您可以使用共享文档:URL方案并提供文件路径,在特定文件夹中打开文件应用程序 例子: func getDocumentsDirectory()->URL{//返回应用程序文件夹 让路径=FileManager.default.url(对于:.documentDirectory,在:.userDomainMask中) 让documentsDirector

我的应用程序中有包含文件的文件夹。如何以编程方式打开带有myapp文件夹的默认文件应用程序

这是文件中GarageBand应用程序的类似文件夹


您可以使用
共享文档:
URL方案并提供文件路径,在特定文件夹中打开
文件
应用程序


例子:
func getDocumentsDirectory()->URL{//返回应用程序文件夹
让路径=FileManager.default.url(对于:.documentDirectory,在:.userDomainMask中)
让documentsDirectory=路径[0]
返回文档目录
}
让path=getDocumentsDirectory().absoluteString.replacingOccurrences(of:“file://”,with:“shareddocuments://”)
让url=url(字符串:路径)!
UIApplication.shared.open(url)

附笔:
欲了解更多信息,请阅读。

这里并不是这样问的。OP正在询问如何使他的应用程序显示为初始目录。@LeoDabus如何以编程方式打开带有myapp文件夹的默认文件应用程序?可能是我弄错了,但我确信在某个给定目录中如何打开文件应用程序存在一个问题。有一个属性
directoryURL
,可以设置为定义起始目录,但我从未成功使用过它@莱奥达伯斯,嗯,我要等行动组回应。如果答案不相关,我将删除它。只是想帮助:)我想打开文件应用程序(作为其他应用程序),而不选择对话框