【问题标题】:Swift - Importing Custom FileSwift - 导入自定义文件
【发布时间】:2019-03-11 00:47:24
【问题描述】:

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

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

这就是我的信息列表的样子

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

2019-03-11 11:28:37.661461+1100 项目[15404:836338] * 断言 -[UIApplication _applicationOpenURLAction:payload:origin:] 中的失败, /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UIApplication.m:6851 2019-03-11 11:28:37.682291+1100 项目[15404:836338] * 终止 应用程序由于未捕获的异常“NSInternalInconsistencyException”, 原因:'应用程序有 LSSupportsOpeningDocumentsInPlace 键,但是 没有在委托上实现 application:openURL:options: '

如何解决这个问题没有“实现 application:openURL:options: on delegate”?

感谢您的帮助

【问题讨论】:

  • 尝试阅读错误信息。它会准确地告诉你该怎么做。

标签: ios swift file-extension info-plist


【解决方案1】:

您需要在您的 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
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多