我正在尝试将UIImagePickerControllerSourceTypeCamera
打开到一个小弹出子视图中,但是每次尝试这个时它都会转到全屏摄像头......这是我第一次尝试使用我读过的相机开发者网站上的所有文档,我都找不到任何解释如何做我想做的事情。
下面是我的startCamera方法,其中我创建一个子视图,然后创建cameraView将cameraView添加到小子视图然后我将它加载到主UIView ....但如上所述它每次都全屏显示:(
任何帮助使这个cameraView看起来像一个小的弹出视图将不胜感激。
#pragma StartCamera
- (IBAction)startCamera:(id)sender {
if (isCameraViewLoaded == NO) {
// Load View for camera
cameraView = [[UIView alloc] initWithFrame:CGRectMake(100.0, 100.0, 200.0, 100.0)];
cameraView.backgroundColor = [UIColor greenColor];
// imagepicker stuff
// check for rear facing camera to continue
if( [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear])
{
// load imagePickController into subview
UIImagePickerController *imagePickController=[[UIImagePickerController alloc]init];
imagePickController.sourceType=UIImagePickerControllerSourceTypeCamera;
imagePickController.delegate=self;
imagePickController.allowsEditing=TRUE;
imagePickController.modalPresentationStyle = UIModalPresentationCurrentContext;
[cameraView addSubview:imagePickController.view];
}
else {
// if there is no camera on the device give warning
UIAlertView *noCameraAlert = [[UIAlertView alloc] initWithTitle:@"Incompatible Device" message:@"Sorry, This feature requiers a rear facing camera" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[noCameraAlert show];
}
// pass camera View to mainview
[self.view addSubview:cameraView];
isCameraViewLoaded = YES;
}else{
[cameraView removeFromSuperview];
isCameraViewLoaded = NO;
}
}