October 2013
Intermediate to advanced
1053 pages
28h 7m
English
You want to be able to store a photo in the user’s photo library.
Use the UIImageWriteToSavedPhotosAlbum
procedure:
-(void)imageWasSavedSuccessfully:(UIImage*)paramImagedidFinishSavingWithError:(NSError*)paramErrorcontextInfo:(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*)pickerdidFinishPickingMediaWithInfo:(NSDictionary*)info{NSLog(@"Picker returned successfully.");NSLog(@"%@",info);NSString*mediaType=info[UIImagePickerControllerMediaType];if([mediaTypeisEqualToString:(__bridgeNSString*)kUTTypeImage]){UIImage*theImage=nil;if([pickerallowsEditing]){theImage=info[UIImagePickerControllerEditedImage];}else{theImage=info[UIImagePickerControllerOriginalImage];}SELselectorToCall=@selector(imageWasSavedSuccessfully:didFinishSavingWithError:\contextInfo:);UIImageWriteToSavedPhotosAlbum(theImage,self,selectorToCall,NULL);}[pickerdismissViewControllerAnimated:YEScompletion:nil];}-(void)imagePickerControllerDidCancel:(UIImagePickerController*)picker{NSLog(@"Picker was cancelled");[pickerdismissViewControllerAnimated:YEScompletion:nil];}-(void)viewDidAppear:(BOOL)animated{[superviewDidAppear:animated];staticBOOLbeenHereBefore=NO;if(beenHereBefore){/* Only display the picker ...
Read now
Unlock full access