iOS如何让程序能够支持文件共享

http://blog.csdn.net/my_programe_life/article/details/49744673

由于iOS的沙盒机制,苹果用户就不能像安卓用户那样能够直接往手机里拷自己喜欢的音视频文件,如果你的程序支持拷贝文件进去,并且能够显示在程序中。

那么就需要以下配置了:

在应用程序的Info.plist文件中添加UIFileSharingEnabled(Application supports iTunes file sharing )键,并将键值设置为YES。
这时你再连接手机运行程序,是不是就可以在itunes里面找到你的程序了,而且可以向里面添加文件。
而在程序中这些文件都是存到Documents目录下了
当需要显示这些文件时,可以找到Documents 的路径,然后直接取数据就行了,关于文件操作,将放在下一篇iOS文件操作来讲
https://support.apple.com/en-us/HT201301

You can copy files between your computer and apps on your iOS device using File Sharing. For example, you can create a document in Pages on your iPad, then copy it to your Mac so that you can open it in Pages for macOS.

Before you begin

Instead of File Sharing, consider using iCloud Drive, Handoff, or AirDrop to keep your documents up to date across all your devices.

iCloud Drive lets you securely access all of your documents from your iPhone, iPad, iPod touch, Mac, or PC. No matter which device you’re using, you'll always have the most up to date documents when you need them.

With Handoff, you can start a document, email, or message on one device and pick up where you left off from another device. Handoff works with Apple apps such as Mail, Safari, Maps, Messages, Reminders, Calendar, Contacts, Pages, Numbers, and Keynote. Some third-party apps are also compatible. 

AirDrop lets you share photos, videos, websites, locations, and more with other nearby Apple devices.

What you need for File Sharing

See which of your iOS apps can share files with your computer

  1. Open iTunes on your Mac or PC.
  2. Connect your iPhone, iPad, or iPod touch to your computer using the USB cable that came with your device.
  3. Click your device in iTunes. Get help if you can't find it. 
  4. In the left sidebar, click Apps. Then, scroll to the File Sharing section at the bottom of the page.
  5. Select an app to see which files are available for sharing in that app on your device. If you don't see a File Sharing section, your device has no file-sharing apps.

Copy files from your computer to your iOS app

  1. In iTunes, select the app from the list in the File Sharing section.
  2. Drag and drop files from a folder or window onto the Documents list to copy them to your device.
    You can also click Add in the Documents list in iTunes, find the file or files you want to copy from your computer, and then click Add. iTunes copies these files to the app on your device. Choose only files that will work with the app. Check the app's user guide to learn which kinds of files will work.

Copy files from an iOS app to your computer

  1. In iTunes, select the app from the list in the File Sharing section.
  2. Drag and drop files from the Documents list to a folder or window on your computer to copy them to your computer.
    You can also select the file or files that you want to copy to your computer from the Documents list and click "Save to," then find the folder on your computer to which you want to copy the files and click Save To.

Open shared files

On your iOS device, you can open the files from your computer with the app that you chose for File Sharing.

You can't access these files from other apps or locations on your device. You can see the list of files in the File Sharing section of iTunes when your device is connected to your computer.

Back up shared files

When iCloud (or iTunes) backs up your device, it backs up your shared files as well. 

If you delete an app with shared files from your iOS device, you also delete those shared files from your device and your iCloud or iTunes backup. To avoid losing shared files, copy the files to your computer before deleting the app from your iOS device.

Delete a shared file from your iOS device

To delete a file you copied to an iOS app using File Sharing, follow these steps:

  1. Open iTunes on your Mac or PC.
  2. Connect your iPhone, iPad, or iPod touch to your computer using the USB cable that came with your device.
  3. Select your device in iTunes. Get help if you can't find it.
  4. In the left sidebar, click Apps. Then, scroll to the File Sharing section.
  5. Select the app with the file that you want to delete.
  6. Select the file that you want to delete in the Documents list, then press the Delete key on your keyboard.
  7. When iTunes asks you to confirm, click Delete.

There might be other ways to delete files from an app. Read your app's user guide to find out more.

Published Date: Sep 22, 2016

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值