gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 05:40:24 27 4
gpt4 key购买 nike

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

System-Declared Uniform Type Identifiers 中的文档未列出允许按 .docx 过滤的公共(public) 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);

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

我目前的解决方案是 C#,但接受了 Objective-C 和 Swift 解决方案。

最佳答案

试试 org.openxmlformats.wordprocessingml.document

关于c# - 在 ios 文档选择器中按 .docx 过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36538257/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com