现在的位置: 首页 > 综合 > 正文

ios文件分享

2013年10月15日 ⁄ 综合 ⁄ 共 2221字 ⁄ 字号 评论关闭

由于最近项目需要读取本地用户的视频..发现无法读取ios设备自带"视频"应用中的视频..很懊恼..4了很多种方法.连assetLibrary都用上了.还不能...国内根本没有..去国外找也没有..

最后发现一些看书软件..办公软件有个文件共享功能..只能以后让用户自己添加到文件共享了...

不给力的apple..还发现苹果自身的软件在播放视频的时候,如果连续快进或后退..一会就应用就挂了..是内存泄露??还是调用出错??

SDK原文:

Sharing Files with the User

An application that wants to make files accessible to the user can do so through the file sharing feature. File sharing exposes the contents of an application’s Documents directory
in iTunes. Exposing this directory allows the user to add files to it or delete files from it. To enable file sharing for your application, do the following:

//下面2句话是重点

  1. Add the UIFileSharingEnabled key to your application’s Info.plist file and set the value of the key to YES.
  2. Put whatever files you want to share in your application’s Documents directory.

When the device is plugged into the user’s computer, iTunes displays a File Sharing section in the Apps pane of the selected device. The user can add files to this directory or move files to the desktop.

Applications that support file sharing should be able to recognize when files have been added to theDocuments directory and respond appropriately. You should never present users with
the list of files in this directory and ask them to decide what to do with those files. Instead, sort through the files programmatically and add files without prompting. Similarly, if users deleted files, remove those files from any relevant parts of your
user interface.

Important: In iTunes, users can manipulate only the top-level items in the Documents directory. Users cannot see the contents of subdirectories but can delete those
directories or copy their contents to the desktop. Take this into consideration when deciding where to put files in this directory.

//这段是如果有自己的文件不想和用户共享就写在Library文件夹里.我一般情况都是些plist文件,用于保存程序相关信息的数据文件,放在Library.

If you do not want files to be shared with the user, put them in your application’s Library directory. If none of the standard Library subdirectories
are appropriate, create a private directory inside the Librarydirectory and give it the name of your application’s bundle ID. You can then use that directory to store any files that
are private to your application.

File sharing does not allow you to share files directly with other applications on the same or a different device. To transfer files between applications, you must use a document interaction controller or the pasteboard. For information on how to use a document
interaction controller, see “Opening Files Whose Type Is Unknown.”


http://blog.csdn.net/h48582291/article/details/6593635

抱歉!评论已关闭.