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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:42:41+00:00 2026-06-08T05:42:41+00:00

//This method Launches the picker to take the picture from camera. -(IBAction)takeyouphoto:(id)sender { if([UIImagePickerController

  • 0
 //This method Launches the picker to take the picture from camera. 
-(IBAction)takeyouphoto:(id)sender
{
     if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {
            // Create image picker controller

            UIImagePickerController *imagePicker2 = [[UIImagePickerController alloc] init];

            // Set source to the camera
            imagePicker2.sourceType =  UIImagePickerControllerSourceTypeCamera;

            // Delegate is self
            imagePicker2.delegate = self;
            // Allow editing of image ?
            imagePicker2.allowsEditing= NO;

            // Show image picker
            [self presentModalViewController:imagePicker2 animated:YES];

        }
}
//This is ImagePicker Delegate method. 
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
 @try {
        NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
 if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) 
        {
            UIImage *resultimage=nil;
            //I am using iOS5, so we can not use NSAutoreleasePool
             resultimage=[info objectForKey:UIImagePickerControllerOriginalImage] ;

            //This Launches the HUD (Activity Indicator) because ImagePicker ususally takes 5  
             //seconds to launch image.
            [self showHUD:resultimage];
         }
    }
       [picker dismissModalViewControllerAnimated:YES];
}
-(void)showHUD:(UIImage *)resultimage
{
    [[Singleton sharedmysingleton] stoptimer];
    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
    [self.navigationController.view addSubview:HUD];

    HUD.delegate = self;
    HUD.labelText = @"Loading Image";
    //HUD.detailsLabelText=@"Loading";
    //Below call on showWhileExecuting of the MBProgressHuD class has its own NSAutoreleasePool
    //Defined in MGProgressHUD class. it also runs the method showimageincell; in separate 
    //thread.

    [HUD showWhileExecuting:@selector(showimagesincell:) onTarget:self withObject:resultimage animated:YES];

}
-(void)showimagesincell:(UIImage *)image
{

    appDelegate.tabbarcontroller.tabBar.userInteractionEnabled=NO;
    NSError *error;

     UIImage *resultImage=[self scale:image toSize:image.size];

    //UIImage *resultImage = [[UIImage alloc] initWithCGImage:imgRefCrop scale:1.0 orientation:resultimage.imageOrientation];

    //resultimage.imageOrientation
    NSData *imagedata=UIImageJPEGRepresentation(resultImage, 0.7);//(resultImage);



    UIImage *smallimage=[self scale:image toSize:CGSizeMake(100, 100)];
    NSData *smallimagedata=UIImageJPEGRepresentation(smallimage, 0.7);

    /* NSString *imagetypeid=[Fetchsavefromcoredata getImagenameandImageidfromdatabase:@"Mobile_ImageType" attributename:@"imageType" predicate:imagetypetxtfield.text];

     //write image to document directory
     NSString *localImagedir=[photodirpath stringByAppendingPathComponent:selectedvinnumber];
     NSString *datetime=[Singleton imagedateandtime];
     NSString *imagename=[NSString stringWithFormat:@"%@_%@.png",imagetypeid,datetime];
     NSString *localImagePath=[localImagedir stringByAppendingPathComponent:imagename];
     [imagedata writeToFile:localImagePath atomically:YES];*/

    [self performSelectorOnMainThread:@selector(updatetableview) withObject:nil waitUntilDone:NO];
}

-(void)updatetableview
{
    [[Singleton sharedmysingleton] starttimer];
    [self viewWillAppear:YES];
}


-(UIImage *)scale:(UIImage *)image toSize:(CGSize)size
{
    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return scaledImage;
}


//Above is all my code, I have tried to find it on diffrent forums but I have not fixed it yet.  
//Any help will be appreciated. Thanks in advance 
  • 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-08T05:42:42+00:00Added an answer on June 8, 2026 at 5:42 am

    The white screen issue is fixed by keeping the image returned by the UIIMagePickerController delegate method into an @autoreleasepool (for iOS5). It solved the problem, we can not use NSAutoreleasePool in ARC code.

    Here the line of code in didFinishPickingMediaWithInfo: delegate method

    UIImage *resultimage=nil;
    @autoreleasepool
    {
              //I am using iOS5, so we can not use NSAutoreleasePool
             resultimage=[info objectForKey:UIImagePickerControllerOriginalImage] ;
    
    }
    

    Below the UIImagePickerController delegate method after implementing @autoreleasepool

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
     @try {
            NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
     if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) 
            {
                UIImage *resultimage=nil;
                @autoreleasepool
               {
                  //I am using iOS5, so we can not use NSAutoreleasePool
                  resultimage=[info objectForKey:UIImagePickerControllerOriginalImage] ;
               }
    
                //This Launches the HUD (Activity Indicator) because ImagePicker ususally takes 5  
                 //seconds to launch image.
                [self showHUD:resultimage];
             }
        }
           [picker dismissModalViewControllerAnimated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take this method /** * @return List of group IDs the person belongs to
This button click method launches a Window called (assemblyname).Reports when a button with Content
I have this class and I have a loop that launches multiple threads from
This method right below reverses a doubly linked list with n elements. I dont
This method works as expected - it creates a JTree with a root node
This method that draws my tiles seems to be quite slow, Im not sure
This method is working totally right in matlab. but, when I compiled it in
Given this method to work on a HTML page in a webbrowser: bool semaphoreForDocCompletedEvent;
This is my javascript method in .aspx file. I want to invoke this method
With this method declaration (no overloads): void Method(double d) { // do something with

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.