开发者

iOS file browser example

开发者 https://www.devze.com 2023-03-08 05:52 出处:网络
Does anyone have some sample code demonstrating how to make a \"file browser\" view?I\'d like to be able to navigate through directories and drill-down the sub-directories and see files located within

Does anyone have some sample code demonstrating how to make a "file browser" view? I'd like to be able to navigate through directories and drill-down the sub-directories and see files located within the various folders. I want the user to be able to create new directories/files and even select an existing file. Is there sample code out there 开发者_JAVA技巧already available to do this?


I don't know about sample code, but this wouldn't be too complicated to achieve using NSFileManager and a UITableView.

You can obtain arrays of directory contents using the subpathsOfDirectoryAtPath:error and associated methods of a file manager. These arrays in turn can populate a UITableView. It would be fairly easy to put together a navigation controller that could display a series of table views showing a file hiearchy.

Bear in mind, however, that you'll only be able to access the directories inside your application sandbox, unless you're running on a jailbroken device.


The iOS programming guide says that

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.

This is assuming you are trying to implement file browse feature for your documents directory.


I'm an author of FileExplorer which is a file browser for iOS and fulfills most of your requirements. Here are some of the features of my control:

  1. Possibility to choose files or/and directories if there is a need for that
  2. Possiblity to remove files or/and directories if there is a need for that
  3. Built-in search functionality
  4. View Audio, Video, Image and PDF files.
  5. Possibility to add support for any file type.

You can find my control here.

0

精彩评论

暂无评论...
验证码 换一张
取 消