iOS 文件浏览器示例
有人有一些示例代码演示如何制作“文件浏览器”视图吗?我希望能够浏览目录并深入子目录并查看位于各个文件夹中的文件。我希望用户能够创建新的目录/文件,甚至选择现有文件。是否有可用的示例代码来执行此操作?
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 already available to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道示例代码,但是使用
NSFileManager
和UITableView
实现这不会太复杂。您可以使用文件管理器的 subpathsOfDirectoryAtPath:error 和关联方法获取目录内容数组。这些数组又可以填充
UITableView
。将导航控制器放在一起相当容易,该控制器可以显示一系列显示文件层次结构的表视图。但请记住,除非您在越狱设备上运行,否则您只能访问应用程序沙箱内的目录。
I don't know about sample code, but this wouldn't be too complicated to achieve using
NSFileManager
and aUITableView
.You can obtain arrays of directory contents using the
subpathsOfDirectoryAtPath:error
and associated methods of a file manager. These arrays in turn can populate aUITableView
. 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.
iOS 编程指南说
这是假设您正在尝试为文档目录实现文件浏览功能。
The iOS programming guide says that
This is assuming you are trying to implement file browse feature for your documents directory.
我是 FileExplorer 的作者,它是一个 iOS 文件浏览器,可以满足您的大部分要求。
以下是我的控件的一些功能:
您可以在此处找到我的控件。
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:
You can find my control here.