Saving a copy of photo to camera roll on iPhone

When you’re taking photo inside the app, you might want to save a copy to Photo library.
Here’s how.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

	// Get the image from the result
	UIImage* originalImage = [info valueForKey:@"UIImagePickerControllerOriginalImage"];  

// Do what you need to do with the image 

	if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
		// save original image to the library
		UIImageWriteToSavedPhotosAlbum (originalImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
	}

}
- (void) image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo {
// do what you need to do after saving
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

HTML tags are not allowed.