IOS 7在相机上崩溃了

时间:2013-10-09 17:11:22

标签: iphone ios ios7

在iOS7上运行以下应用程序时,我的应用程序崩溃了。 它在iOS6上工作得很好

UIImagePickerController *ImagePicker;

@try {
   ImagePicker = [[[UIImagePickerController alloc]init]autorelease];
   ImagePicker.sourceType= UIImagePickerControllerSourceTypeCamera;
   ImagePicker.showsCameraControls = NO;
   ImagePicker.toolbarHidden = YES;
   ImagePicker.navigationBarHidden= YES;
   //  ImagePicker.wantsFullScreenLayout = YES;

   ImagePicker.cameraViewTransform = CGAffineTransformScale(ImagePicker.cameraViewTransform, CAMERA_TRANSFORM, CAMERA_TRANSFORM);  
}
@catch (NSException *exception) {
    [ImagePicker release];
    ImagePicker = nil;
}
@finally {

    if(ImagePicker)
    {
        [cameralayer addSubview:[ImagePicker view]];
        [cameralayer release];
    }

}

1 个答案:

答案 0 :(得分:0)

当您到达将其视图添加到ImagePicker的行时,您无法保证cameralayer将在内存中。创建后不要autorelease ImagePicker。一旦你真正使用它及其视图,只有release