UIImagePickerController After taking 5 images sequentially Terminates Application .
===

    
     //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
                @autoreleasepool 
                {
                     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 