0
我已經使用下面的代碼將選取的圖像存儲到文檔目錄中。不能在文檔目錄中看到選取的圖像
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
UIImage *img = [editingInfo objectForKey:UIImagePickerControllerOriginalImage];
NSData *imageData = UIImagePNGRepresentation(img);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setDateFormat:@"yyyy-MM-dd,HH:mm:ss"];
NSString *imageName = [NSString stringWithFormat:@"photo-%@.png",
[dateFormatter stringFromDate:[NSDate date]]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
[imageData writeToFile:fullPathToFile atomically:YES];
imageView.image=image;
NSLog(@"path %@",fullPathToFile);// shows the complete image path
[self dismissModalViewControllerAnimated:YES];
}
可惜我看不到在文件目錄中攝取的圖像,我用「fullPathToFile」可變內容,瀏覽器網址是否可用或者not..But它不是.. 問你的幫助。
感謝..但圖像不能在打印路徑查找.. ;-( – 2013-02-11 12:04:48
你在模擬器測試它檢查您的文件?目錄在模擬器中,如果圖像文件被創建或沒有 – 2013-02-11 12:09:59
是啊,我檢查了網址... 用戶/用戶名/庫/應用程序支持/ iPhone模擬器/ 6.0 /應用程序/ F3535242-FF08-417B-BD08-4F2EAD1D27A2/Documents/ – 2013-02-11 12:18:16