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)
}