use*_*096 20 xcode objective-c xcode4
如何使用NSFileManager将UIImage保存到文件?
谢谢,
Jon*_*lli 54
开始了.
这会将a存储UIImage到iOS App的文档目录中.你不需要NSFileManager.
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
UIImage * imageToSave = [UIImage imageNamed:@"Icon.png"];
NSData * binaryImageData = UIImagePNGRepresentation(imageToSave);
[binaryImageData writeToFile:[basePath stringByAppendingPathComponent:@"myfile.png"] atomically:YES];
Run Code Online (Sandbox Code Playgroud)
编辑: 如果您从iOS相机存储图像,您可能会看到如何将图像旋转到正确的方向.在这种情况下看这里.
| 归档时间: |
|
| 查看次数: |
29200 次 |
| 最近记录: |