-3

我想通过编码在电子邮件中添加文档(图像除外)。我知道我们可以访问设备图片库,但我想访问设备的文档。

我们可以像 imagepicker 一样访问文档吗?

4

2 回答 2

0

我了解您想要一个可视文件浏览器,因此请尝试NSOutlineView
检查这个(类似)问题
使用 NSOutlineView 作为文件浏览器,从给定目录
或本教程开始:
http ://www.alauda.ro/2012/04/30/nsoutlineview-inside-out/

或使用NSFileManager手动处理文件(但这似乎不是您要寻找的,但无论如何......)
http://www.techotopia.com/index.php/Working_with_Directories_in_Objective-C#Getting__a_Directory_File_Listing

实际上,我不相信有任何像 UIImagePicker 那样简单易用的文件和文件夹浏览器,所以我猜 NSOutlineView 将是您的最佳选择。

于 2013-10-16T06:48:11.563 回答
0

不,您不能从与设备库( by UIImagePickerView)相同的文档目录访问图像

但是,如果您想从文档目录中获取特定图像,请使用以下代码。

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *newPath = [documentsDirectory stringByAppendingPathComponent:@"NameOFImage"]; // put name of image which you want to get it from document directory
    UIImage *myImage = [UIImage imageWithContentsOfFile:newPath];

这里myImage是您要从文档目录中获取的图像,

于 2013-10-16T06:25:20.030 回答