美文网首页
iOS过滤类型 UIDocumentPickerViewCont

iOS过滤类型 UIDocumentPickerViewCont

作者: 你飞跃俊杰 | 来源:发表于2023-06-04 20:16 被阅读0次
///定于类型
typedef enum {
    BNIMFileTypeimage=1<<0,
    BNIMFileTypevideo=1<<1,
    BNIMFileTypeaudio=1<<2,
    BNIMFileTypexls=1<<3,
    BNIMFileTypexlsx=1<<4,
    BNIMFileTypedoc=1<<5,
    BNIMFileTypedocx=1<<6,
    BNIMFileTypepdf=1<<7,
    BNIMFileTypetxt=1<<8,
} BNIMFileType;

///将传入的字符串转换成对应的类型
+(BNIMFileType)getFileType:(NSArray *)array{
    BNIMFileType type = 0;
    if([array containsObject:@"video"]){
        type = type|BNIMFileTypevideo;
    }
    if([array containsObject:@"audio"]){
        type = type|BNIMFileTypeaudio;
    }
    if([array containsObject:@"xls"]){
        type = type|BNIMFileTypexls;
    }
    if([array containsObject:@"xlsx"]){
        type = type|BNIMFileTypexlsx;
    }
    if([array containsObject:@"doc"]){
        type = type|BNIMFileTypedoc;
    }
    if([array containsObject:@"docx"]){
        type = type|BNIMFileTypedocx;
    }
    if([array containsObject:@"pdf"]){
        type = type|BNIMFileTypepdf;
    }
    if([array containsObject:@"txt"]){
        type = type|BNIMFileTypetxt;
    }
    if([array containsObject:@"image"]){
        type = type|BNIMFileTypeimage;
    }
    return type;
}
////转换成苹果自带的类型
+(NSArray *)getDocumentTypes:(BNIMFileType)type{
    NSMutableArray *array = NSMutableArray.array;
    if(type&BNIMFileTypevideo){
        [array addObject:@"public.movie"];
    }
    if(type&BNIMFileTypeaudio){
        [array addObject:@"public.audio"];
    }
    if(type&BNIMFileTypexls){
        [array addObject:@"com.microsoft.excel.xls"];
    }
    if(type&BNIMFileTypexlsx){
        [array addObject:@"com.microsoft.excel.xlsx"];
    }
    if(type&BNIMFileTypedoc){
        [array addObject:@"com.microsoft.word.doc"];
    }
    if(type&BNIMFileTypedocx){
        [array addObject:@"com.microsoft.word.docx"];
    }
    if(type&BNIMFileTypepdf){
        [array addObject:@"com.adobe.pdf"];
    }
    if(type&BNIMFileTypetxt){
        [array addObject:@"public.text"];
    }
    if(type&BNIMFileTypeimage){
        [array addObject:@"public.image"];
    }
    return array;
}
///转换成其他类型,比如聊天记录

使用

- (void)selectiCloudFile{
//    NSArray *documentTypes = @[@"public.content", @"public.text", @"public.source-code", @"public.image", @"public.audiovisual-content", @"com.adobe.pdf", @"com.apple.keynote.key", @"com.microsoft.word.doc", @"com.microsoft.excel.xls", @"com.microsoft.powerpoint.ppt"];
    NSArray *documentTypes = nil;
    if([self.docTypeArray isKindOfClass:NSArray.class]&&self.docTypeArray.count){
        documentTypes = [BNIMFileUploadOrSendManager getDocumentTypes:[BNIMFileUploadOrSendManager getFileType:self.docTypeArray]];
    }
    UIDocumentPickerViewController *documentPickerViewController = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:documentTypes inMode:UIDocumentPickerModeOpen];
    documentPickerViewController.delegate = self;
    [_mainVC presentViewController:documentPickerViewController animated:YES completion:nil];
}

相关文章

  • iOS 过滤下载资源类型

    以视频下载为例: 在做下载功能时,有时候会遇到后台给提供了非视频资源的下载链接,如下方法可将非视频资源过滤掉

  • 回答 | 4道过滤菜鸟的iOS面试题

    回答 | 4道过滤菜鸟的iOS面试题 回答 | 4道过滤菜鸟的iOS面试题

  • flutter中过滤特殊字符

    单引号在flutter中过滤报错兼容问题ios的过滤[/\:*?<>|‘”“’] 其中ios输入的单引号是‘,a...

  • 前嗅ForeSpider脚本教程:链接过滤脚本

    链接过滤脚本是地址和标题过滤中的脚本, 过滤类型必须选择脚本过滤时过滤脚本才能生效,过滤脚本用于处理复杂的链接或标...

  • Spring Cloud Zuul过滤器详解

    过滤器类型与请求生命周期 Zuul大部分功能都是通过过滤器来实现的。Zuul中定义了四种标准过滤器类型,这些过滤器...

  • 输入框过滤操作

    定义过滤类型 扩展UIVIew 执行操作

  • 优质文集

    iOS UIWebView URL拦截 实现网页过滤,URL拦截

  • 自定义 logback 日志过滤器

    Logback 提供两种类型的过滤器,常规过滤器和turbo过滤器。本例讲述基于常规过滤器的自定义实现。 常规过滤...

  • SpringBoot配置ZuulFilter过滤器详解

    Zuul大部分功能都是通过过滤器来实现的,Zuul中定义了四种过滤器类型,这些过滤器类型对应的生命周期: PRE:...

  • vue过滤器+计算属性

    过滤器 作用:让要显示在页面上的内容进行重新筛选 类型:全局过滤器局部过滤器 格式: 全局过滤器: html部分 ...

网友评论

      本文标题:iOS过滤类型 UIDocumentPickerViewCont

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