February 2012
Intermediate to advanced
872 pages
22h 43m
English
You want to be able to store a photo in the user’s photo library.
Use the UIImageWriteToSavedPhotosAlbum
procedure:
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{ if (paramError == nil){ NSLog(@"Image was saved successfully."); } else { NSLog(@"An error happened while saving the image."); NSLog(@"Error = %@", paramError); } } - (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ NSLog(@"Picker returned successfully."); NSLog(@"%@", info); NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType]; if ([mediaType isEqualToString:(__bridge NSString *)kUTTypeImage]){ UIImage *theImage = nil; if ([picker allowsEditing]){ theImage = [info objectForKey:UIImagePickerControllerEditedImage]; } else { theImage = [info objectForKey:UIImagePickerControllerOriginalImage]; } SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:); UIImageWriteToSavedPhotosAlbum(theImage, self, selectorToCall, NULL); } [picker dismissModalViewControllerAnimated:YES]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{ NSLog(@"Picker was cancelled"); [picker dismissModalViewControllerAnimated:YES]; } - (void)viewDidLoad{ [super viewDidLoad]; if ([self isCameraAvailable] && [self doesCameraSupportTakingPhotos]){ UIImagePickerController ...Read now
Unlock full access