Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7070489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:34:22+00:00 2026-05-28T05:34:22+00:00

May be this question is too easy or I did not know how easy

  • 0

May be this question is too easy or I did not know how easy it will be.

I have an actionsheet to allow the user to choose how if they want to take a photo or select from camera.

The app will save user taken photo regardless is selected from camera roll or taken from camera. Am I missing something?

Thanks for reading my question.

#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];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:34:22+00:00Added an answer on May 28, 2026 at 5:34 am

    Try this code.. Its working properly from my side.

    - (IBAction) uploadPhoto:(id)sender
    {
            UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@""
                                                                     delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
                                                            otherButtonTitles:@"Use Photo from Library", @"Take Photo with Camera", nil];
            actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
            actionSheetAction = ActionSheetToSelectTypeOfSource;
            [actionSheet showInView:self.view];
            [actionSheet release];
    }
    
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
        UIImagePickerControllerSourceType sourceType;
                    if (buttonIndex == 0) {
                        sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                    } else if(buttonIndex == 1) {
                        sourceType = UIImagePickerControllerSourceTypeCamera;
                    }else {
                        // Cancel
                        break;
                    }
                    if([UIImagePickerController isSourceTypeAvailable:sourceType]) {
                        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
                        picker.sourceType = sourceType;
                        picker.delegate = self;
                        if (sourceType == UIImagePickerControllerSourceTypeCamera) {
                            picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
                        }
                        picker.allowsImageEditing = NO;
                        [self presentModalViewController:picker animated:YES];
                        [picker release];
                    }
    
    }
    
    #pragma mark -
    #pragma mark UIImagePickerControllerDelegate
    
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
       UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
       NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  NSUserDomainMask, YES);
     NSString *docDirectory = [paths objectAtIndex:0];
     NSString *imgPath = [documentsDirectory stringByAppendingPathComponent:[NSString  stringWithFormat:@"image1.png"]];
    
    //COnvert it to NSData before saving and then save it
        NSData *imgData = UIImagePNGRepresentation(image);
        [imgData writeToFile:imgPath atomically:YES];
       [self dismissModalViewControllerAnimated:YES];
    }
    
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
        [self dismissModalViewControllerAnimated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may be too product specifc but I'd like to know if anyone
may be too simple groovy question but....please help i have a list like this:
(This question is asked on Maven User mailing list too) I have recently faced
This question may sound too silly, however , I don't find concrete answer any
Well, I'm learning Scala so this question may be too basic for most people.
i'm a long-time newbie to c#, and this question may be too obvious, so
Alright, I am going to state up front that this question may be too
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
this question may seem too basic to some, but please bear with be, it's
I know that my this question may sound pathetic to you but as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.