应用冻结相机快门

时间:2013-11-21 07:00:21

标签: ios memory-management ios6

我正在使用iOS 7开发应用程序。有时候,当我打开相机时,我在iOS 6设备中遇到问题。它冻结在相机快门上。虽然我把ARC设置为YES。我无法理解问题在哪里?

我使用了这个代码

self.cameraUI = [[UIImagePickerController alloc] init];
self.cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
self.cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];

self.cameraUI.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.cameraUI.navigationBarHidden = YES;

self.cameraUI.showsCameraControls = NO;

self.cameraUI.wantsFullScreenLayout = YES;
self.cameraUI.delegate = self;

[self.cameraView addSubview:self.cameraUI.view];

1 个答案:

答案 0 :(得分:0)

您不应该addSubview:UIImagePickerController的观点进行操作。相反,建议使用UIImagePickerController并实现其委托以获取所选图像。

来自Apple docs for How to use UIImagePickerController?

  

显示用户界面。在iPhone或iPod touch上,通过调用当前活动视图控制器的presentViewController:animated:completion:方法,以模态方式(全屏)执行此操作,将配置的图像选取控制器作为新视图控制器传递。

这是你可以从控制器中呈现它的方式,

[viewcontrollerObj presentViewController:self.cameraUI animated:YES completion:nil];

希望有所帮助!