简体   繁体   English

如何在iPhone / iPad SDK中从Internet下载或打开.docx,.pdf,.zip和视频文件

[英]How do I download or open .docx,.pdf,.zip and video file from internet in iphone/ipad SDK

Developing an iPad/iphone app below are my requirements: I'm consuming webservice where i get the list of absolute internet file paths (.docx, .pdf, .zip, video) and file names that are displaying in UITableView. 以下是开发iPad / iphone应用程序的要求:我正在使用Webservice,从中获取Internet绝对文件路径(.docx,.pdf,.zip,视频)和UITableView中显示的文件名的列表。 Now when I click on any file it should give me few options download,save or open. 现在,当我单击任何文件时,应该会给我几个下载,保存或打开的选项。

The query is how do I open and save these files using iphone/ipad SDK. 该查询是如何使用iphone / ipad SDK打开和保存这些文件。

I tried this code [but] its opening in Browser. 我尝试过此代码[但]在浏览器中将其打开。

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:myFilePath]];

Thanks in advance.. 提前致谢..

For downloading and saving file there are many methods available. 用于下载和保存文件的方法很多。 One of them is explained in following answer. 下面的答案解释了其中之一。

method to download mp3 file from url 从网址下载mp3文件的方法

Other possible option can be to download file in form in synchronous form. 其他可能的选择可以是以同步形式下载文件。 One possible way can be using 一种可能的方法是使用

[NSData dataWithContentOfURL:] ; [NSData dataWithContentOfURL:] ;

Above will rerurn autoreleased datawhich can be saved to fileusing full path. 上面将删除自动释放的数据,这些数据可以使用完整路径保存到文件中。

Opening file is a matter that depends upon type of file so for that you have to look for how you can open particular file. 打开文件是一个取决于文件类型的问题,因此您必须寻找如何打开特定文件的方法。

If you need any help regarding how to make destination location path etc. then there are many other post available for that. 如果您需要有关如何设置目标位置路径等方面的帮助,那么还有很多其他文章可供选择。 Or you can post here also. 或者您也可以在这里发布。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM