【发布时间】:2017-11-29 05:34:41
【问题描述】:
我想做与在苹果文档中解释本文相同的事情,但在 Appcelerator Titanium 中。我搜索了 Appcelerator 网站并没有找到方法。有人知道吗? https://developer.apple.com/library/content/qa/qa1587/_index.html
【问题讨论】:
标签: ios types titanium appcelerator document
我想做与在苹果文档中解释本文相同的事情,但在 Appcelerator Titanium 中。我搜索了 Appcelerator 网站并没有找到方法。有人知道吗? https://developer.apple.com/library/content/qa/qa1587/_index.html
【问题讨论】:
标签: ios types titanium appcelerator document
您需要在tiapp.xml 中注册您希望能够处理的文件:
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<ios>
<plist>
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Add to Housters</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.adobe.pdf</string>
<string>com.microsoft.word.doc</string>
</array>
</dict>
</array>
</dict>
</plist>
</ios>
</ti:app>
然后,在您的应用程序代码中,每次触发resume 事件(例如,Ti.App.addEventListener('resume', resume);),您可以查看Ti.App.getArguments().url 以查看您的应用程序是否已通过另一个应用程序打开。在我的应用程序中,我会这样做,另外我会扫描Inbox 文件夹以查看是否有任何内容。当另一个应用程序在您的应用程序中打开一个文档时,它会被复制到此目录中,然后您的应用程序就会启动。所以Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'Inbox').getDirectoryListing() || [] 会给你一个包含所有文档的数组,然后你可以将其移出该目录,或者处理和删除。
【讨论】:
Inbox 中查找文件的部分。 (我不敢看这是否是推荐的做法,因为它工作得很好!)