0

UIImagePickerControllerを使用して、iPadの写真ライブラリからUIImageを取得しました。ここで、その画像をアプリに関連付けられ、既に追加された画像を含むディレクトリに保存したいと考えています。ディレクトリのURLも取得しました。

例: file://localhost/Users/administrator/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/31816EF9-AE1E-40DF-93C4-C67A82E4B85B/Documents/7884/Images/

指定したディレクトリに uiimage を保存するにはどうすればよいですか?

4

1 に答える 1

1

このコードを使用して、ドキュメント ディレクトリに保存します。

NSData *pngData = UIImagePNGRepresentation(image);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
NSString *documentsPath = [paths objectAtIndex:0]; 
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"image.png"]; 
[pngData writeToFile:filePath atomically:YES]; 
于 2013-01-09T12:19:40.440 に答える