要向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#,但目标-c和快速解决方案被接受.
发布于 2016-04-11 01:03:42
试试org.openxmlformats.wordprocessingml.document
发布于 2022-04-13 06:24:52
试着让supportedTypes: UTType = UTType.content
https://stackoverflow.com/questions/36538257
复制相似问题