7

My app works fine on all the devices and ios versions but when it comes to ipad mini, on iOS7 when i alloc:init the UIImagePickerController and display. After getting image the app suddenly give low memory warning and crash. Here is my code of capturing image.

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
    UIImagePickerController *imagePickerController;
    if ([UIUtilityClass isCurrentVersionIsIOS7OrGreater]) {
        UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init];
        [imagePickerController setDelegate:self];
        imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage,nil];
        imagePickerController.allowsEditing=NO;
        CGFloat scaleFactor=1.3f;

        switch ([UIApplication sharedApplication].statusBarOrientation) {
            case UIInterfaceOrientationLandscapeLeft:
                imagePickerController.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * 90 / 180.0), scaleFactor, scaleFactor);
                break;
            case UIInterfaceOrientationLandscapeRight:
                imagePickerController.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * -90 / 180.0), scaleFactor, scaleFactor);
                break;
            case UIInterfaceOrientationPortraitUpsideDown:
                imagePickerController.cameraViewTransform = CGAffineTransformMakeRotation(M_PI * 180 / 180.0);
                break;
            default:
                break;
        }

    }
    else
    {
        imagePickerController = [[NonRotatingUIImagePickerController alloc] init];
        imagePickerController.delegate = self;
        imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage,nil];
        imagePickerController.allowsEditing = YES;
    }


    popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
    popoverController.delegate=self;
    [popoverController presentPopoverFromRect:CGRectMake(626,142,120,135) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [imagePickerController release];
    newMedia = YES;

}

After that i capture the image using following code.

 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
 {


[popoverController dismissPopoverAnimated:true];
[popoverController.delegate popoverControllerDidDismissPopover:popoverController];

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
int orientation=image.imageOrientation;
image=[image imageToFitSize:PIC_SIZE method:MGImageResizeCrop];
    switch (orientation) {
        case UIImageOrientationUp:
            // do nothing
            break;
        case UIImageOrientationDown:
            image=[image imageRotatedByDegrees:180.0];
            break;
        case UIImageOrientationLeft:
            image=[image imageRotatedByDegrees:90.0];
            image=[image imageRotatedByDegrees:180];
            break;
            //2
        case UIImageOrientationRight:
            image=[image imageRotatedByDegrees:-90.0];
            image=[image imageRotatedByDegrees:180];
            break;
        default:
            break;
    }

   }
Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56
NaXir
  • 2,373
  • 2
  • 24
  • 31
  • Are you fixed this memory warning crash in iPad mini ? Kindly suggest me, How to handle this situation ? – Mani Nov 15 '13 at 09:18
  • I haven't got any solution yet. – NaXir Nov 16 '13 at 16:22
  • I am also getting the same problem but i discovered , while debugging from xcode it crashes , but while launching app as a normal user form device, it works fine.... seems there is a bug in iOS – HarshIT Nov 18 '13 at 07:18
  • 1
    It sometimes works fine for me, especially on devices other than ipad mini it works always fine. On iPad Mini it usually crashes more often. – NaXir Nov 19 '13 at 11:26
  • Please let me know if you find the solution for this. This is driving me crazy :( – Pawan Sharma Dec 12 '13 at 07:25
  • Hi, Kindly let me know, any one got the answer for this issue in iPad Mini ? – Mani Jan 30 '14 at 15:35
  • nope still no solution. – NaXir Jan 30 '14 at 16:44
  • @NaXir do you have answer now? or just ask client that you should use latest iPAD – Nitya Jul 02 '14 at 13:59
  • @Nitya Still no luck.Its a app with few million users and we have to make it work on every device. Its crashing only on ipad mini image picker. On every other device it works pretty fine. – NaXir Jul 03 '14 at 06:20
  • @NaXir What a shame !! But I am sure image picker (on Apple mini) - Camera app doest not crash! there must be way to doing it. I will keep searching... – Nitya Jul 03 '14 at 09:39

1 Answers1

0

Did you test it without the release call to the imagePickerController? If you are using ARC, I don't think you need to do this.