我的应用程序适用于所有设备和ios版本但是当涉及到ipad mini时,在iOS7上我分配:init UIImagePickerController并显示。获取图像后,应用程序突然发出低内存警告并崩溃。这是我拍摄图像的代码。
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;
}
}
答案 0 :(得分:0)
你是否在没有对imagePickerController的释放调用的情况下测试它?如果您使用ARC,我认为您不需要这样做。