我正试图在我的应用程序中将图像发送到instagram,就像现在许多照片应用程序一样。我学习了一些从UIDocumentInteractionController导入文档的教程,但它不起作用。
也许因为所有的教程都是关于如何打开PDF文件,以及打开发送到instagram的.ig文件,我需要更多的东西?
无论如何,我编辑了我的plist,添加了以下行:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>LSItemContentTypes</key>
<array>
<string>com.instagram.photo</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleTypeName</key>
<string>Ig Document</string>
<key>LSHandlerRank</key>
<string>Default</string>
</dict>
</array>
现在我的应用程序出现在UIDocumentInteractionController菜单中,但当我点击"在MyPhotoApp中打开"时,菜单会关闭,什么也没发生。
我尝试在方法中设置一个断点:(BOOL)应用程序:(UIApplication*)应用程序openURL:(NSURL*)url source应用程序:
但它似乎从未被调用过。我错过了什么?
好的,明白了。我在plist上遗漏了以下几行:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>ig</string>
</dict>
<key>UTTypeIdentifier</key>
<string>com.instagram.photo</string>
<key>UTTypeDescription</key>
<string>Ig Photo</string>
</dict>
</array>
现在它正在上运行