我在UIImagePickerController
的帮助下使用自定义相机。我正在继承UIImagePickerController
类并使用without present / dismiss。我们只是打开自定义相机视图和拍照。一段时间后点击相机takepicture方法被调用,应用程序正在崩溃。在此期间没有调用委托方法。我的代码是这样的:
-(void)viewDidLoad
{
if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear] && self.camType==2)
{
self.sourceType=UIImagePickerControllerSourceTypeCamera;
self.cameraDevice=UIImagePickerControllerCameraDeviceRear;
self.showsCameraControls = NO;
self.wantsFullScreenLayout=NO;
self.navigationBar.hidden=NO;
self.cameraOverlayView = mainView;
}
}
else
{
self.navigationBar.hidden=YES;
self.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[notAllowBtn setHidden:TRUE];
[cmView setHidden:TRUE];
}
self.delegate=self;
[self.view addSubview:cmView];
}
-(void)cameraTakePic {
if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) {
[self takePicture];
}
}
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info{
if (![info objectForKey:@"UIImagePickerControllerOriginalImage"]) {
NSArray *arr=[[appDel navController] viewControllers];
id obj=[arr lastObject];
UIViewController *objContr=((UIViewController *)obj);
objContr.navigationController.navigationBar.userInteractionEnabled = YES;
[clickBtn setEnabled:YES];
return;
}
UIImage* image = nil;
UIImage *imageTemp = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
答案 0 :(得分:1)
来自Apple UIImagePickerController
类引用:
UIImagePickerController类仅支持纵向模式。这个 class旨在按原样使用,不支持子类化。 此类的视图层次结构是私有的,不得修改, 除了一个例外。您可以为自定义视图分配 cameraOverlayView属性并使用该视图来显示其他内容 信息或管理相机界面之间的交互 和你的代码。
您不应该继承UIImagePickerController
类,而应该使用AVFoundation并制作自定义捕获方法。