在ios文档选择器中通过.docx进行筛选
本文关键字:docx 筛选 ios 文档 选择器 | 更新日期: 2024-07-27 04:03:23
要向UIDocumentMenuViewController
提供什么统一类型标识以允许用户选择*.docx文件?
系统声明的统一类型标识符中的文档没有列出允许按.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);
我在黑暗中拍摄了一张照片,并包含了标识符com.microsoft.word.docx
,但它不会触发docx的过滤。
我目前的解决方案是C#,但接受了objective-C和swift解决方案。
尝试org.openxmlformats.wordprocessingml.document
尝试let supportedTypes:[UTType]=[UTType.content]