美文网首页
iOS 之 Share Extension

iOS 之 Share Extension

作者: 秋叶红90 | 来源:发表于2021-07-06 17:43 被阅读0次

    Application Extension 扩展 分享

    第一添加扩展支持 info.plist

    <key>UIFileSharingEnabled</key>
        <string>YES</string>
    
    
    <key>CFBundleDocumentTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeName</key>
                <string>public.movie</string>
                <key>LSHandlerRank</key>
                <string>Owner</string>
                <key>LSItemContentTypes</key>
                <array>
                    <string>public.3gpp2</string>
                    <string>public.mpeg</string>
                    <string>public.avi</string>
                    <string>com.apple.quicktime-movie</string>
                    <string>public.3gpp</string>
                    <string>public.video</string>
                    <string>public.movie</string>
                    <string>public.mpeg-4</string>
                </array>
            </dict>
            <dict>
                <key>CFBundleTypeName</key>
                <string>public.plain-text</string>
                <key>LSHandlerRank</key>
                <string>Owner</string>
                <key>LSItemContentTypes</key>
                <array>
                    <string>public.plain-text</string>
                </array>
            </dict>
            <dict>
                <key>CFBundleTypeName</key>
                <string>image</string>
                <key>LSHandlerRank</key>
                <string>Owner</string>
                <key>LSItemContentTypes</key>
                <array>
                    <string>public.png</string>
                    <string>com.apple.macpaint-image</string>
                    <string>com.apple.pict</string>
                    <string>public.camera-raw-image</string>
                    <string>public.jpeg-2000</string>
                    <string>public.jpeg</string>
                    <string>public.image</string>
                    <string>com.kodak.flashpix.image</string>
                    <string>com.ilm.openexr-image</string>
                    <string>com.sgi.sgi-image</string>
                    <string>com.adobe.photoshop-image</string>
                    <string>com.adobe.illustrator.ai-image</string>
                    <string>com.compuserve.gif</string>
                    <string>com.microsoft.bmp</string>
                    <string>com.microsoft.ico</string>
                    <string>com.truevision.tga-image</string>
                </array>
            </dict>
        </array>
    
    

    添加扩展 Share Extension (怎么添加分享扩展到项目可以百度)

    自定义UI 核心代码

    override func loadView() {
            custom.backgroundColor = .red
            self.view = custom
        }
    
    

    主App 和 扩展通讯数据使用通知 项目添加group

    let userDefaults = UserDefaults.init(suiteName: "group.rrr.rrr")
    
    

    剩下看demo 吧

    相关文章

      网友评论

          本文标题:iOS 之 Share Extension

          本文链接:https://www.haomeiwen.com/subject/zywgultx.html