jar*_*ryd 5 iphone cocoa-touch
是否可以将iphone上相机拍摄的图像保存到自定义目录或iphone上的某个位置,而不是保存到相机胶卷?
我想将图像保存到设备,然后在稍后阶段访问,而不是使用ALAssets从相机胶卷读取.
这可能吗?
是的,您可以将它们保存到应用程序的文档文件夹中.这是一个例子:
// Create path
NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/ImageName.png"];
// Write image to PNG
[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES];
Run Code Online (Sandbox Code Playgroud)
要检索它:
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
Run Code Online (Sandbox Code Playgroud)
列出目录中的所有文件:
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager directoryContentsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]];
for (NSString *s in fileList){
NSLog(s);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
671 次 |
| 最近记录: |