我試圖寫入到磁盤的圖像,讓他們以後:寫作照片(和其他東西)到磁盤,並在iphone
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString* savePath = [documentsPath stringByAppendingPathComponent:@"photo"];
BOOL result = [data writeToFile:savePath atomically:YES];
if(result) NSLog(@"Save of photo success!");
然後,後來,我嘗試檢索表視圖細胞圖像:
NSData* getPhoto = [NSData dataWithContentsOfFile:[leaf content]];
UIImage* myImage = [UIImage imageWithData:getPhoto];
cell.imageView.image = myImage;
是的,我檢查以確保[leaf content]返回與savePath相同的NSString。還有什麼可能是這個問題? [NSData dataWithContentsOfFile:[leaf content]];
返回nil ....
編輯:我在做,我稱之爲將writeToFile在這條路上的原始數據:
NSData* dataToAdd = UIImageJPEGRepresentation(image, 1.0);
謝謝你們
你如何創建你的數據對象? – Vladimir 2010-03-16 08:53:34