zoukankan      html  css  js  c++  java
  • 文件“选择其它应用打开”及文件共享功能

    一:选择其它应用打开

    如图:可以将QQ或微信的zip文件拷贝到第三方App的沙盒中,Document文件夹下,方便用户操作使用

    1:具体操作将下面Code添加到info.plish文件里面

    <key>CFBundleDocumentTypes</key>
    
        <array>
    
            <dict>
    
                <key>CFBundleTypeIconFiles</key>
    
                <array>
    
                    <string>icon-hex</string>
    
                    <string>icon-hex@2x</string>
    
                </array>
    
                <key>CFBundleTypeName</key>
    
                <string>Distribution Packet (ZIP)</string>
    
                <key>CFBundleTypeRole</key>
    
                <string>Viewer</string>
    
                <key>LSHandlerRank</key>
    
                <string>Default</string>
    
                <key>LSItemContentTypes</key>
    
                <array>
    
                    <string>com.pkware.zip-archive</string>
    
                </array>
    
            </dict>
    
            <dict>
    
            <key>CFBundleTypeIconFiles</key>
    
           <array>
    
           <string>icon_22x29</string>
    
           <string>icon_44x58</string>
    
           <string>icon_64x64</string>
    
           <string>icon_320x320</string>
    
           </array>
    
           <key>CFBundleTypeName</key>
    
           <string>allFiles</string>
    
           <key>LSHandlerRank</key>
    
           <string>Owner</string>
    
           <key>LSItemContentTypes</key>
    
           <array>
    
           <string>public.data</string>
    
           </array>
    
           </dict>
    
        </array>

    具体原理可以参考:(转发SeraZheng)https://www.jianshu.com/p/88a08d66894f 

    二:文件分享

          PS:将本地文件分享到QQ或微信中,一般文件格式需要压缩包

          

      //分享文件
    NSURL *url = [NSURL fileURLWithPath:myFilePath];//需要打开的文件url //在这里呢 如果想分享图片 就把图片添加进去 文字什么的通上 NSArray *activityItems = @[url]; UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil]; //不出现在活动项目 activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll,UIActivityTypeMail]; [self presentViewController:activityVC animated:YES completion:nil]; // 分享之后的回调 activityVC.completionWithItemsHandler = ^(UIActivityType _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) { if (completed){ //分享 成功 NSLog(@"completed"); }else{ //分享 取消 NSLog(@"cancled"); } };

       

  • 相关阅读:
    POJ 1269 Intersecting Lines --计算几何
    URAL 2014 Zhenya moves from parents --线段树
    HDU 4122 Alice's mooncake shop --RMQ
    HDU 4121 Xiangqi --模拟
    HDU 4045 Machine scheduling --第二类Strling数
    HDU 4041 Eliminate Witches! --模拟
    HDU 5105 Math Problem --数学,求导
    2014-2015 Codeforces Trainings Season 2 Episode 7 G Gophers --线段树
    HDU 4419 Colourful Rectangle --离散化+线段树扫描线
    HDU 5102 The K-th Distance
  • 原文地址:https://www.cnblogs.com/nelsen-chen/p/8384224.html
Copyright © 2011-2022 走看看