在 ios 文档选择器中按 .docx 过滤

mat*_*dev 6 c# objective-c ios xamarin

提供给 a以允许用户选择 *.docx 文件的统一类型标识符是什么UIDocumentMenuViewController

System-Declared Uniform Type Identifiers中的文档没有列出允许按 .docx 过滤的公共 UTType。标准 *.doc 文件存在标识符但 *.docx 不存在,是否有替代 UTType?

这是我当前的代码:

var allowedDocumentTypes = new string[] {
    UTType.RTF,
    UTType.Text,
    UTType.PDF,
    UTType.UTF8PlainText,
    UTType.RTFD,
    UTType.UTF16ExternalPlainText,
    UTType.UTF16PlainText,
    UTType.UTF8PlainText,
    UTType.FlatRTFD,
    "com.microsoft.word.doc",
    "com.microsoft.word.docx" // An attempt to include docx filtering.
};

var pickerMenu = new UIDocumentMenuViewController(allowedDocumentTypes, UIDocumentPickerMode.Open);
pickerMenu.DidPickDocumentPicker += (sender, args) =>
{
    args.DocumentPicker.DidPickDocument += (sndr, pArgs) =>
    {
        var securityEnabled = pArgs.Url.StartAccessingSecurityScopedResource();

        FileInfo fi = new FileInfo(pArgs.Url.Path);

        var result = new SelectFileResult();
        result.FilePath = fi.FullName;
        result.FileName = fi.Name;

        NSUrlRequest urlReq = NSUrlRequest.FromUrl(pArgs.Url);
        NSUrlResponse response;
        NSError error;;
        var data = NSUrlConnection.SendSynchronousRequest(urlReq, out response, out error);

        result.MimeType = response.MimeType;

        Action onFileConsumeDone = () =>
        {
            pArgs.Url.StopAccessingSecurityScopedResource();
        };

        onFileSelected(result, onFileConsumeDone);

    };

    // Display the document picker
    AppDelegate.TopViewController.PresentViewController(args.DocumentPicker, true, null);
};

pickerMenu.ModalPresentationStyle = UIModalPresentationStyle.Popover;
AppDelegate.TopViewController.PresentViewController(pickerMenu, true, null);
Run Code Online (Sandbox Code Playgroud)

我在黑暗中拍摄并包含了标识符,com.microsoft.word.docx但它不会触发 docx 过滤。

我当前的解决方案是 C#,但接受了 Objective-c 和 swift 解决方案。

Jas*_*son 7

尝试 org.openxmlformats.wordprocessingml.document