一:选择其它应用打开
如图:可以将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"); } };