試試這個:
- (void)saveImage: (UIImage*)image
{
if (image != nil)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [documentsDirectory stringByAppendingPathComponent:
@"test.png" ];
NSData* data = UIImagePNGRepresentation(image);
[data writeToFile:path atomically:YES];
}
}
- (UIImage*)loadImage
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [documentsDirectory stringByAppendingPathComponent:
@"test.png" ];
UIImage* image = [UIImage imageWithContentsOfFile:path];
[self sendAction:path];
return image;
}
感謝響應這是我目前完成的,在這裏我們再次存儲在一個特定的文件路徑的圖像,我的問題是沒有任何選項來獲得的路徑,而不是存儲它 – thavasidurai 2013-04-25 14:07:22
是否有一個選項可以在將它發送到服務器後刪除該路徑? – thavasidurai 2013-04-25 14:10:49
@Mutawe:你能告訴我如何從相同的路徑刪除圖像? for this +1 – python 2013-07-12 10:37:40