iOS7 自定义 UTI

标签 ios ios7 uti

我正在把我的头撞到墙上,但似乎无法让我的自定义 UTI 工作。

我正在努力在我的应用程序中实现 AirDrop,这样我就可以在设备之间共享文件。我能够成功地将文件传输到其他设备,但是安装了我的应用程序的其他设备将无法在我的应用程序中打开文件。

这是我的 app.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>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>MYAPP</string>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array>
                <string>57x57</string>
            </array>
            <key>CFBundleTypeName</key>
            <string>MYAPPNAME Shared Assignment</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.MYAPPNAME.SIAASSIGNMENT</string>
            </array>
        </dict>
    </array>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIcons</key>
    <dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>57x57 2.png</string>
                <string>114x114 2.png</string>
                <string>72x72 2.png</string>
                <string>144x144 2.png</string>
            </array>
        </dict>
    </dict>
    <key>CFBundleIdentifier</key>
    <string>com.MYAPPNAME.${PRODUCT_NAME:rfc1034identifier}</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>4.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>4.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSMainNibFile</key>
    <string>Main_Window</string>
    <key>NSMainNibFile~ipad</key>
    <string>Main_Window_iPad</string>
    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>remote-notification</string>
    </array>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UIStatusBarTintParameters</key>
    <dict>
        <key>UINavigationBar</key>
        <dict>
            <key>Style</key>
            <string>UIBarStyleDefault</string>
            <key>Translucent</key>
            <false/>
        </dict>
    </dict>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.text</string>
            </array>
            <key>UTTypeDescription</key>
            <string>MYAPPNAME Shared Assignment</string>
            <key>UTTypeIdentifier</key>
            <string>com.MYAPPNAME.SIAASSIGNMENT</string>
            <key>UTTypeSize320IconFile</key>
            <string>72x72</string>
            <key>UTTypeSize64IconFile</key>
            <string>57x57</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>com.MYAPPNAME.SIAASSIGNMENT</key>
                <array>
                    <string>SIAASSIGNMENT</string>
                                <key>public.mime-type</key>
                                <string>application/xml</string>
                </array>
            </dict>
        </dict>
    </array>
</dict>
</plist>

我已经尝试了很多不同的方法来完成这项工作,但我似乎无法让 iOS7 认识到这是我的文件类型。我知道您不应该为您的 UTI 使用“public.xxx”命名空间,因为这些命名空间是由 Apple 预先分配的。
任何帮助将不胜感激!

最佳答案

确保您 declare the types as imported以便 iOS 知道将您的应用程序显示为打开它们的选项。

另外,确保你实现了 -application:openUrl:sourceApplication:annotation:通过 AirDrop 或文档交互 Controller 接收文件。

关于iOS7 自定义 UTI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19569612/

相关文章:

ios - 我可以将选择器添加到其他类吗?

objective-c - 检查建议的文件扩展名是否有效/系统上已注册的文件扩展名

ios - 确定图像选择器媒体类型是否为视频

ios - 具有可选 IBOutlet 的属性多态性

ios - MoPub 如何使用具有动态单元格高度的 MPTableViewAdPlacer 实现 iOS 原生广告?

ios - 使用测量单位以编程方式获取功耗

macos - 如何为 OSX 注册自定义非文档 UTI/文件类型以识别它?

ios - 如果让pngImageData = UIImageJPEGRepresentation(img !, 0.25),应用程序崩溃了

ios - WeMo SDK for iOS 架构问题

iOS 7 添加 UIView 到 UITableView