我將影像保存到nsdocumentdirectory這樣添加的UIImage在nsdocumentdirectory和檢索
NSArray *pathArr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [[pathArr objectAtIndex:0]
stringByAppendingPathComponent:@"img.data" ];
NSLog(@"path=%@",path);
NSData *retrievedData = [NSData dataWithContentsOfFile:path];
imgView.image=[UIImage imageWithData:retrievedData];
的問題只有一個圖像被保存。如果我嘗試顯示圖像,則會顯示上次保存的圖像。如何解決這個問題?
嘗試將圖像保存爲plist。使用索引您可以訪問您保存的所有圖像。 –
從哪裏得到這些圖像?它只會保存一張圖像,因爲它們被覆蓋。 –
from相冊 –