应用程序运行时,swift sourceApplication无法正常工作

时间:2018-02-05 20:05:11

标签: ios swift xcode

AppDelegate

   func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {        
        return true
    }

info.plist中

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFile</key>
            <string>Icon-App-60x60</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>net.mycomp.myapp.pdf</string>
            </array>
            <key>CFBundleTypeName</key>
            <string>PDF data type</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
        </dict>
    </array>
    <key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeDescription</key>
            <string>PDF dosyalarını çevir</string>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.text</string>
            </array>
            <key>UTTypeIdentifier</key>
            <string>net.mycomp.myapp.pdf</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <string>pdf</string>
            </dict>
        </dict>
    </array>

我希望在我的应用中打开pdf文件。当我的应用程序关闭应用程序没有崩溃,但当应用程序运行应用程序崩溃。

另外,如果我删除了sourceApplication应用程序没有崩溃

1 个答案:

答案 0 :(得分:1)

这是一种弃用的方法试试这个

 func application(_ app: UIApplication,
                 open url: URL,
                 options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool

{
}