7

私のアプリはすべてのデバイスと ios バージョンで正常に動作しますが、iPad mini に関しては、iOS7 で UIImagePickerController を alloc:init して表示します。画像を取得した後、アプリは突然メモリ不足の警告を出し、クラッシュします。ここに画像をキャプチャする私のコードがあります。

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;

}

その後、次のコードを使用して画像をキャプチャします。

 -(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;
    }

   }
4

1 に答える 1