iOS将App做成可在文件分享打开中出现

用法去下,只要在Info.plist中配置上对应文件类型就行,如图(以PDF文件作为示例)

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>com.adobe.pdf</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.adobe.pdf</string>
            </array>
        </dict>
    </array>

添加完之后,然后微信里打开一个pdf并且点击上边的三个点看分享

你看我们的App出现在可选列表了,这一部分算是搞定了。然后就是我们需要处理点击我们App过后的处理

//直接在appDelegate里边这个方法里处理,url即选择文件的路径
    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

        return true
    }
0 0 投票数
文章评分
订阅评论
提醒
guest
0 评论
内联反馈
查看所有评论
京ICP备17066706号-1
0
希望看到您的想法,请您发表评论x