0
)写真ライブラリから選択した画像を自分のアプリのメインバンドルに保存することは可能ですか?私は、あなたがXcodeのアプリケーションのメインバンドルに書き込めないことをどこかに読んだと思った。これが真実でなければ、どうすればそれをやり遂げることができるだろう。写真ライブラリから画像をメインバンドルに保存する(Xcode
)写真ライブラリから選択した画像を自分のアプリのメインバンドルに保存することは可能ですか?私は、あなたがXcodeのアプリケーションのメインバンドルに書き込めないことをどこかに読んだと思った。これが真実でなければ、どうすればそれをやり遂げることができるだろう。写真ライブラリから画像をメインバンドルに保存する(Xcode
Use this code to save image from photo Library to Main Bundle
- (void)saveImage:(UIImage*)image withImageName:(NSString*)imageName {
NSData *imageData = UIImagePNGRepresentation(image); //convert image into .png format.
NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
NSString *documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageName]]; //add our image to the path
[fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; //finally save the path (image)
}