首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xamarin iOS :过滤掉文档选取器上的FileType显示

Xamarin iOS :过滤掉文档选取器上的FileType显示
EN

Stack Overflow用户
提问于 2017-01-23 08:22:59
回答 3查看 3.4K关注 0票数 2

我试图过滤掉所有的文件,其中不是图像,视频,音频,pdf和其他文档文件,如微软。

目前,我的代码中包含以下内容:

代码语言:javascript
复制
var allowedUTIs = new string[] {
            UTType.Image,
            UTType.PDF,
            UTType.Video,
            UTType.Audio,
            UTType.Movie,
            UTTYPE.Text,
            "com.microsoft.word.doc",
            "com.microsoft.excel.xls",
            "com.microsoft.powerpoint.ppt",
            "org.openxmlformats.wordprocessingml.document"
        };

主要关注的是自定义的类型。它是否涵盖了所有microsoft offices文件类型: doc、xls、ppt、docx等。

是否还有其他我没有介绍的文档类型,例如苹果的特定文档文件。

EN

回答 3

Stack Overflow用户

发布于 2017-03-23 15:31:05

代码语言:javascript
复制
        var allowedUtis = new string[] {
            UTType.UTF8PlainText,
            UTType.PlainText,
            UTType.RTF,
            UTType.PNG,
            UTType.Text,
            UTType.PDF,
            UTType.Image,
            UTType.UTF16PlainText,
            UTType.FileURL,
            "com.microsoft.word.doc",
            "org.openxmlformats.wordprocessingml.document",
            "com.microsoft.powerpoint.​ppt"
            "org.openxmlformats.spreadsheetml.sheet",
            "org.openxmlformats.presentationml.presentation",
            "com.microsoft.excel.xls"
        };

这些是我的UTTypes

在这里,对于文档"com.microsoft.word.doc",对于文档"org.openxmlformats.wordprocessingml.document“等等。我已经对所有的文档进行了测试。

票数 5
EN

Stack Overflow用户

发布于 2021-01-12 21:00:11

或者您可以像这样使用

代码语言:javascript
复制
       var fileTypes = new string[] {
        "public.utf8-plain-text", 
        "public.plain-text", 
        "public.text",
        "public.png", 
        "public.jpeg", 
        "com.microsoft.bmp",           
        "public.composite-content" 
        "com.adobe.pdf",
        "public.image", 
        "public.file-url", 
        "com.microsoft.word.doc",
        "org.openxmlformats.wordprocessingml.document",
        "com.microsoft.powerpoint.​ppt",
        "org.openxmlformats.spreadsheetml.sheet",
        "org.openxmlformats.presentationml.presentation",
        "com.microsoft.excel.xls"
         };

https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html

编辑

使用Xamarin essentials

代码语言:javascript
复制
    var customFileType = new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
   {
     {              
      DevicePlatform.Android, fileTypes
     },
     {
        DevicePlatform.iOS, fileTypes
     }
   });
       

 var file = await FilePicker.PickAsync(new PickOptions
 {
    PickerTitle = "Please select a file",
    FileTypes = customFileType,
 });
票数 4
EN

Stack Overflow用户

发布于 2019-08-07 19:05:13

允许视频,和音频文件也有一个选项,如果不添加,它会显示文件,但禁用你不能挑选。

代码语言:javascript
复制
var allowedUTIs = new string[]
{
    UTType.UTF8PlainText,
    UTType.PlainText,
    UTType.RTF,
    UTType.PNG,
    UTType.Text,
    UTType.PDF,
    UTType.Image,
    UTType.UTF16PlainText,
    UTType.FileURL,
    UTType.Spreadsheet,
    UTType.MP3,
    UTType.MPEG4,
    UTType.MPEG4Audio,
    UTType.WaveformAudio,
    UTType.Audio,
    UTType.Video,
    UTType.GIF,
    UTType.BMP,
    "org.openxmlformats.wordprocessingml.document",
    "com.microsoft.powerpoint.​ppt",
    "org.openxmlformats.spreadsheetml.sheet",
    "org.openxmlformats.presentationml.presentation",
    "com.microsoft.excel.xls",
    "com.microsoft.waveform-​audio",
    "com.microsoft.windows-​media-wmv",
    "com.adobe.illustrator.ai-​image"
};

苹果文档:https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41797644

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档