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 8763545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:48:13+00:00 2026-06-13T15:48:13+00:00

I am using UIImagePickerController to select the image from the PhotoLibrary in my application.

  • 0

I am using UIImagePickerController to select the image from the PhotoLibrary in my application. I have used two different approaches for this. At first I have used a class variouble UIImagePicker with below code.

     imagepicker = [[UIImagePickerController alloc]init];
     imagepicker.delegate = self;
     imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
     imagepicker.modalTransitionStyle = UIModalTransitionStylePartialCurl;
     [self presentModalViewController:self.imagepicker animated:YES];

Above code is working fine.But when I clicked on the button it is taking some time to react with the animation in this case.Then I used the autorelease pool approach with this method

    NSAutoreleasePool *pool;
    pool = [[NSAutoreleasePool alloc] init]; 
    if([UIImagePickerController isSourceTypeAvailable:
        UIImagePickerControllerSourceTypePhotoLibrary])
    {
        UIImagePickerController *picker= [[[UIImagePickerController alloc]init]autorelease];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        picker.modalTransitionStyle = UIModalTransitionStylePartialCurl;
        [self presentModalViewController:picker animated:YES];

    }
    [pool release];

Also works charm. Both of them showing no leak in the analyser.Can anybody point me the right approach.

  • 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-06-13T15:48:14+00:00Added an answer on June 13, 2026 at 3:48 pm

    Well, no much to say here… Both approaches work, both approaches are correct, use whichever you prefer.

    One minor point: if you are regularly presenting the image picker, you better use the first method, and assign it to an instance variable (it isn’t called a “class variable”!) only for the first time, and don’t release it until - dealloc – this way, you save the continuous allocation-deallocation of the image picker every single time the user chooses an image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application i want to select the video from library by using UIImagePickerController.
I'm new to iPhone and I'm using this code to select an image from
I am using a UIImagePickerController to allow users to select an image from the
I have captured image from iphone using the below UIImagePickerController delegate method. - (void)
I am taking pictures from the iPhone camera using the UIImagePickerController Class. I am
I have an iPhone application using a UIImagePickerController . As sourceType I have UIImagePickerControllerSourceTypePhotoLibrary
In my project I am using the UIIamgepickercontroller to select an image from the
In my iPad application, I'm letting the user select an image using the following
I'm using UIImagePickerController to allow my user to select a video from the asset
I am using the UIImagePickerController in order to let the user select an image

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.