iPhone文件共享:如何识别文件何时添加?
我在我的应用程序中通过 iTunes 进行文件共享(参考 iOS 3.2 中的新增功能)通过启用 UIFileSharingEnabled 键,但根据文档:
“支持文件共享的应用程序应该能够识别何时添加文件到文档目录并做出适当的回应。”
我的问题是,如果我的应用程序正在运行,然后用户决定添加文件,我该如何响应此事件?我要响应什么事件?
换句话说,我知道添加文件时我的 iPhone 应用程序需要做什么,但不确定将该“响应”代码放在哪里。目前,如果我的应用程序正在运行(也可能在后台运行)并且添加了一个文件,则查看此添加文件的效果的唯一方法是强制退出应用程序,然后重新启动应用程序。
I have file sharing via iTunes working in my application (reference What's New in iOS 3.2) by enabling the UIFileSharingEnabled key, but according to the documentation:
"Applications that support file sharing should be able to recognize when files have been added to the Documents directory and respond appropriately."
My question is, if my application is running, and then the user decides to add a file, how do I respond to this event? And what event is it that I would respond?
In other words, I know what my iPhone application needs to do when a file is added but not sure where to put this "responding" code. Currently, if my application is running (could be running in the background as well) and a file is added, the only way to see the effects of this added file is by force-quitting the application and then re-launching the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要记住,您的应用程序并不是真正在后台运行,或者当文件添加到设备时根本没有运行。为了让用户将文件添加到设备,他需要在 iTunes 中同步它。因此,同步完成后,您的应用程序将重新启动或恢复,在这两种情况下,您的应用程序委托中都有方法,您可以使用这些方法来检查是否将新文件添加到应用程序中。
You need to remember that your app isn't really running in the background, or at all for that matter when files are added to the device. In order for the user to add files to device he needs to sync it in iTunes. So after the sync is done, your app will either be relaunched, or resumed, in both these cases you have methods in your app delegate which you can use to check if new files were added to to the application.