简体   繁体   English

如何在iOS中的Objective-C中从设备选择任何文档文件

[英]how to choose any document file from device in objective-c in ios

how to access any document files from device to our application for uploading to server and downloading from server ,save in device not in App can any one help me how to do this? 如何将任何文档文件从设备访问到我们的应用程序以上传到服务器和从服务器下载,保存在设备中而不是App中,有人可以帮助我做到这一点吗? i searched from many days, but i didn't get any solution to how to get files from the device. 我搜索了很多天,但没有得到如何从设备中获取文件的任何解决方案。

UIDocumentInteractionController *pdfPicker = [[UIDocumentInteractionController alloc] init];
pdfPicker.delegate = self; // ensure you set the delegate so when a PDF is chosen the right method can be called

[self presentViewController:pdfPicker animated:YES completion:nil];

i also implemented this code but its crashing the app. 我也实现了此代码,但它使应用程序崩溃。 please help me, thanks in Advance. 请帮助我,谢谢预先。

Not Possible, You can not get list of documents available in other app from your app. 不可能,您无法从您的应用程序获取其他应用程序中可用的文档列表。 however, if you want to bring files from other other app to your app you can implement following: 但是,如果要将文件从其他应用程序带到您的应用程序,则可以实现以下功能:

1) Register your app for supporting file type by defining required values in plist. 1)通过在plist中定义所需的值来注册您的应用以支持文件类型。 in this way, when user will see file in mail, safari or some other app, they will see your app in open with option. 这样,当用户看到邮件,野生动物园或其他应用程序中的文件时,他们将打开您的应用程序,并带有选项。 how to register the app to open the pdf file in my app in ipad 如何在ipad中注册应用程序以在我的应用程序中打开pdf文件

2) Create share extension: whenever user will share file which you are supporting, they will see your app in option. 2)创建共享扩展名:每当用户共享您支持的文件时,他们都会在选项中看到您的应用程序。

Code to share file path/file between a share extension and iOS app 在共享扩展程序和iOS应用之间共享文件路径/文件的代码

from both option above, you will get selected document path into your app. 从以上两个选项中,您都将获得选定文档路径到您的应用程序中。 you can upload that doc to server if required. 您可以根据需要将该文档上传到服务器。

It is not possible to access all files in an iOS device outside the sandbox of the app. 无法访问应用程序沙箱外部的iOS设备中的所有文件。 What you can do is: 您可以做的是:

  • Access all the files in Gallery using UIImagePickerController. 使用UIImagePickerController访问Gallery中的所有文件。
  • Access all the user files in network- Dropbox/Google drive/iCloud. 访问网络-Dropbox / Google驱动器/ iCloud中的所有用户文件。 They all have separate public APIs that can be downloaded and used to download/upload files in network. 它们都有单独的公共API,可以下载这些公共API,并使用它们来下载/上传网络中的文件。

In this way, you can access most of the user files and use the same in your application. 这样,您可以访问大多数用户文件,并在应用程序中使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Document目录获取文件路径 - Objective-c iOS - Get file path from Document directory - Objective-c iOS 从Objective-C iOS 9启动设备Twitter设置 - Launch device twitter settings from objective-c iOS 9 从iOS设备使用Objective-C将图像文件上传到PHP - Upload imagefile from iOS device with objective-c to an PHP 如何使用Objective-C从IOS Cordova中的设备(本地DB)删除图像 - How to delete a image from Device (Local DB) in IOS Cordova using Objective-C 你如何将推送对象从 Urban Airship (Objective-c) 发送到 iOS 设备? - How do you get the push object sent to iOS device from Urban Airship (Objective-c)? Objective-C:将图像从文件复制到设备粘贴板 - Objective-C: Copy images from file to device pasteboard iOS / Objective-C / imagePicker:跳过“选择”步骤 - IOS/Objective-C/imagePicker: Skip 'Choose' step 如何使用Objective-C在IOS应用中上传.xml文件? - How to upload .xml file in IOS app using Objective-C? 如何使用 ios (objective-c) 客户端将文件发布到 Blobstore - How to post file to Blobstore using ios (objective-c) client 如何使用evaluateJavaScript 将数据从WKWebview 发送到HTML 文件 | iOS | 目标-C - How to send data from WKWebview to HTML file using evaluateJavaScript | iOS | Objective-C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM