Swift - 导入自定义文件

问题描述 投票:-2回答:1

我正在尝试使用下面的教程在我的应用程序中导入和打开自定义文件

https://chariotsolutions.com/blog/post/importing-data-via-custom-file-types-in/

这就是我的信息plist看起来像enter image description here

当我拖动扩展名为“.AMarkUp”的文件时,应用程序崩溃了

2019-03-11 11:28:37.661461 + 1100项目[15404:836338] *断言失败 - [UIApplication _applicationOpenURLAction:payload:origin:],/ BuildRoot / Library / Cache / com.apple.xbs / Source / UIKitCore_Sim / UIKit-3698.93.8 / UIApplication.m:6851 2019-03-11 11:28:37.682291 + 1100 Project [15404:836338] *由于未捕获的异常'NSInternalInconsistencyException'而终止app,原因:'Application有LSSupportsOpeningDocumentsInPlace键,但不是实现应用程序:openURL:options:on delegate'

如何解决此问题并不“实现应用程序:openURL:options:on delegate”?

谢谢您的帮助

ios swift file-extension info-plist
1个回答
2
投票

您需要在AppDelegate.swift文件中实现指定的UIApplicationDelegate方法。

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
    // handle the file here

    return true // or false based on whether you were successful or not
}
© www.soinside.com 2019 - 2024. All rights reserved.