美文网首页
iOS 调用第三方APP打开文件

iOS 调用第三方APP打开文件

作者: _相信未来_ | 来源:发表于2020-08-22 10:50 被阅读0次

在做好解压缩以及文件打开之后,说界面难看,醉了,不得已又开始研究调用第三方打开文件,以WPS为例
首先判断设备上是否安装有WPS

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"KingsoftOfficeApp://"]]){
        //说明此设备有安装app
        NSLog(@"安装");
    }else{
        //说明此设备没有安装app
        NSLog(@"没有安装");
    };

在此提供一些常用的第三方APP的url scheme

微信 :weixin://
高德地图:iosamap://
淘宝网:taobao://
支付宝:alipay://
新浪微博:weibo://
优酷:youku://
知乎:zhihu://
WPS:KingsoftOfficeApp://

接下来使用 UIDocumentInteractionController 就可以将文件分享出去打开

@property (nonatomic, strong) UIDocumentInteractionController *documentVC;
需要遵循代理
<UIDocumentInteractionControllerDelegate>
随后在需要的地方
- (void)showDocumentVCPath:(NSString *)pathUrl {
    self.documentVC = [[UIDocumentInteractionController alloc]init];
    NSString *pathStr = [NSString stringWithFormat:@"file://%@",pathUrl];
    self.documentVC = [UIDocumentInteractionController interactionControllerWithURL:[NSURL URLWithString:pathStr]];
    [self.documentVC setDelegate:self];
    [self.documentVC presentOpenInMenuFromRect:CGRectZero inView:self.viewController.view animated:YES];
}

iOS中加载word以及各类文档

iOS解压zip和rar文件

iOS根据文件路径判断是文件还是文件夹

相关文章

网友评论

      本文标题:iOS 调用第三方APP打开文件

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