我正在尝试使用这行代码
[UIImagePNGRepresentation(image, 1.0) writeToFile:pngPath atomically:YES];但显然pngPath是未声明的。所以我必须使用stringByAppendingPathComponent。
我用谷歌搜索了这方面的例子,我找到了这个
myPlistPath = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.plist", plistName] ];
[myPlistPath retain];
问题是我没有plist文件,因为我不需要它。如何解决所有这些问题并对UIImage镜像执行writeToFile操作?
发布于 2010-11-04 22:37:17
我不完全理解您的问题,但要获得文件应保存的完整路径,您可以尝试如下所示:
NSString *file = @"myfile.png";
NSString *directory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];
NSString *path = [directory stringByAppendingPathComponent: file];然后:
[UIImagePNGRepresentation(image) writeToFile:path atomically:YES];https://stackoverflow.com/questions/4097693
复制相似问题