Xamarin iOS MusicXML文件在UIDocumentPickerViewController

时间:2018-05-30 09:57:56

标签: file xamarin.ios icloud-drive musicxml uidocumentpickerviewcontroller

我有一个用C#编写的Xamarin iOS项目。 我已经实现了一个 UIDocumentPickerViewController ,可以将外部文件导入我的应用程序。 PDF和XML在iOS 11上的功能类似于以下代码:

// Allow the Document picker to select a range of document types
var allowedUTIs = new string[] {
                                    UTType.PDF,
                                    UTType.XML,
                                    "com.recordare.musicxml",
                                    "com.recordare.musicxml.uncompressed",
                                    "public.data",
                                    "public.mxl",
                                    "public.content"
};

 UIDocumentPickerViewController picker = new UIDocumentPickerViewController(allowedUTIs, UIDocumentPickerMode.Import);

然而 .mxl 文件,即MusicXML文件在文件应用程序(DocumentPicker视图)中显示为灰色。

在我的Info.plist文件中,我有以下文档类型

Document Types

以及导入的UTI

Document Types

我谷歌搜索MusicXML社区宣布的官方UTI。在他们的网站上,我只发现了有关提议的UTI的讨论,说明如下: https://forums.makemusic.com/viewtopic.php?f=12&t=2510

  

附件是一个XML文件(也在本电子邮件的底部),其中包含针对MusicXML的UTI声明的提议,该提议基于Apple文档中提供的信息。   我们使用了以下类型标识符:   未压缩的MusicXML:com.musicxml.musicxml   Compressed MusicXML:com.musicxml.musicxml-compressed

我也在我的Info.plist中尝试了这两个UTI( com.musicxml.musicxml com.musicxml.musicxml-compressed )。它仍然没有用。

有人可以帮帮我吗?

编辑1: 在这里,您可以看到整个Info.plist文件:

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>UTImportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeIdentifier</key>
            <string>com.recordare.musicxml.uncompressed</string>
            <key>UTTypeReferenceURL</key>
            <string>http://www.musicxml.org/</string>
            <key>UTTypeDescription</key>
            <string>MusicXML</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>xml</string>
                </array>
                <key>public.mime-type</key>
                <array>
                    <string>application/vnd.recordare.musicxml+xml</string>
                </array>
            </dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.data</string>
                <string>public.content</string>
            </array>
        </dict>
        <dict>
            <key>UTTypeIdentifier</key>
            <string>com.recordare.musicxml</string>
            <key>UTTypeReferenceURL</key>
            <string>http://www.musicxml.org/</string>
            <key>UTTypeDescription</key>
            <string>MusicXML</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>mxl</string>
                </array>
                <key>public.mime-type</key>
                <array>
                    <string>application/vnd.recordare.musicxml</string>
                </array>
            </dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.data</string>
                <string>public.content</string>
            </array>
        </dict>
        <dict>
            <key>UTTypeDescription</key>
            <string>Midi</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>mid</string>
                </array>
                <key>public.mime-type</key>
                <array>
                    <string>audio/midi</string>
                </array>
            </dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.data</string>
                <string>public.content</string>
            </array>
            <key>UTTypeIdentifier</key>
            <string>public.data</string>
        </dict>
    </array>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.xml</string>
            </array>
            <key>CFBundleTypeName</key>
            <string>MusicSheet</string>
        </dict>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>MusicSheet</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.recordare.musicxml</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>MusicSheet</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.recordare.musicxml.uncompressed</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeName</key>
            <string>PDF</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.adobe.pdf</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeName</key>
            <string>Midi</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.data</string>
            </array>
        </dict>
    </array>
    <key>MinimumOSVersion</key>
    <string>9.3</string>
    <key>UIAppFonts</key>
    <array>
        <string>Fonts/companySymbols.ttf</string>
        <string>Fonts/webhostinghub-glyphs.ttf</string>
    </array>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
        <integer>2</integer>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>CFBundleIdentifier</key>
    <string>com.company.test1</string>
    <key>XSAppIconAssets</key>
    <string>Resources/Images.xcassets/AppIcons.appiconset</string>
    <key>CFBundleShortVersionString</key>
    <string>1.2.0</string>
    <key>CFBundleName</key>
    <string>Test1</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>microphone use</string>
    <key>CFBundleDisplayName</key>
    <string>Test1</string>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>XSLaunchImageAssets</key>
    <string>Resources/Images.xcassets/LaunchImage.launchimage</string>
    <key>CFBundleVersion</key>
    <string>16</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
    </array>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>com.company.test1</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb899828993298981</string>
                <string>com.company.test1</string>
                <string>com.googleusercontent.apps.989898989981191-232111s4lsf441cu94</string>
            </array>
            <key>CFBundleURLTypes</key>
            <string>Viewer</string>
        </dict>
    </array>
</dict>
</plist>

2 个答案:

答案 0 :(得分:0)

您是否设置了UTTypeTagSpecification来列出与com.recordare.musicxml相关联的文件扩展名? 我没有在你的截图中看到这个(但我对Xamarin UI也不是很熟悉)

答案 1 :(得分:0)

我无法帮助Xamarin,但是MusicXML 3.1添加了官方的UTI。此更改在https://www.w3.org/2017/12/musicxml31/的MusicXML 3.1社区组报告中列出。您可以在https://github.com/w3c/musicxml/blob/gh-pages/schema/container.dtd上找到它们的文档。