Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to prevent saving picture from camera roll again
    text
    copied!<p>May be this question is too easy or I did not know how easy it will be.</p> <p>I have an actionsheet to allow the user to choose how if they want to take a photo or select from camera.</p> <p>The app will save user taken photo regardless is selected from camera roll or taken from camera. Am I missing something?</p> <p>Thanks for reading my question.</p> <pre><code>#pragma mark - photo select -(IBAction)showCameraAction:(id)sender { if(![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Choose Photo From Library", nil]; actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic; actionSheet.tag =1; [actionSheet showInView:[self.view superview]]; } else { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo With Camera", @"Choose Photo From Library", nil]; actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic; actionSheet.tag =1; [actionSheet showInView:[self.view superview]]; } } - (void)getPhotoFromSource:(UIImagePickerControllerSourceType)sourceType; { //NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType]; if ([UIImagePickerController isSourceTypeAvailable:sourceType]) { //NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType]; UIImagePickerController *picker = [[UIImagePickerController alloc] init]; //picker.mediaTypes = mediaTypes; picker.delegate = self; //picker.allowsEditing = YES; picker.sourceType = sourceType; [self presentModalViewController:picker animated:YES]; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error accessing media" message:@"Device doesn't support media source" delegate:nil cancelButtonTitle:@"Drat" otherButtonTitles:nil, nil]; [alert show]; } } #pragma mark UIImagePickerController delegate methods -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { self.lastChosenMediaType = [info objectForKey:UIImagePickerControllerOriginalImage]; imageFrame=fImageView.frame; //UIImage *chosenImage = [info objectForKey:UIImagePickerControllerEditedImage]; UIImage *orginalImage = [info objectForKey:UIImagePickerControllerOriginalImage]; UIImage *shrunkenImage = shrinkImage(orginalImage,imageFrame.size); self.fImage = shrunkenImage; fImageView.image = frogImage; //answer fix, to prevent saving picture from cameraroll again. if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { UIImageWriteToSavedPhotosAlbum(orginalImage, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), nil); } [picker dismissViewControllerAnimated:YES completion:nil]; } - (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { //NSString *message; //NSString *title; // if (!error) { // title = NSLocalizedString(@"SaveSuccessTitle", @""); // message = NSLocalizedString(@"SaveSuccessMessage", @""); // } else { // title = NSLocalizedString(@"SaveFailedTitle", @""); // message = [error description]; // } // UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title // message:message // delegate:nil // cancelButtonTitle:NSLocalizedString(@"ButtonOK", @"") // otherButtonTitles:nil]; // [alert show]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload