Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios iPad uiimagepickercontroller专用前置摄像头_Ios_Ipad_Camera_Uiimagepickercontroller - Fatal编程技术网

Ios iPad uiimagepickercontroller专用前置摄像头

Ios iPad uiimagepickercontroller专用前置摄像头,ios,ipad,camera,uiimagepickercontroller,Ios,Ipad,Camera,Uiimagepickercontroller,我有一个iPad应用程序,应该只使用设备上的前置摄像头 问题是,在我使用前摄像头拍摄第一张照片后,如果用户选择重拍照片,则使用后摄像头,如果再次重拍,则使用正确的前摄像头 每次点击拍摄图片时,我都会释放图像采集器和弹出窗口,显示我的相机预览和图像 - (void)setUpImagePicker { //poner photo picker en pop up! BOOL hasCamera = [UIImagePickerController isSourceTypeAvail

我有一个iPad应用程序,应该只使用设备上的前置摄像头

问题是,在我使用前摄像头拍摄第一张照片后,如果用户选择重拍照片,则使用后摄像头,如果再次重拍,则使用正确的前摄像头

每次点击拍摄图片时,我都会释放图像采集器和弹出窗口,显示我的相机预览和图像

- (void)setUpImagePicker
{
    //poner photo picker en pop up!
    BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];

    picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.sourceType = hasCamera ? UIImagePickerControllerSourceTypeCamera :    UIImagePickerControllerSourceTypePhotoLibrary; 
    picker.cameraDevice = UIImagePickerControllerCameraDeviceFront; 
    [picker setShowsCameraControls:FALSE];
    CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 0.0);
    picker.cameraViewTransform = translate;
    CGAffineTransform scale = CGAffineTransformScale(translate, 1, 1);
    picker.cameraViewTransform = scale;

    self.companyPopOverController = [[[UIPopoverController alloc] initWithContentViewController:picker] autorelease];
    self.companyPopOverController.passthroughViews=[NSArray arrayWithObject:self.view]; 
    [self createTimer];
}
- (NSTimer*)createTimer {

    // create timer on run loop
    return [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(timerTicked:) userInfo:nil repeats:NO];
}

- (void)timerTicked:(NSTimer*)timer {

    [self.companyPopOverController presentPopoverFromRect:CGRectMake(622, 534, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
- (void)takePicButtonPressed:(id)sender
{
    NSLog(@"takePicButtonPressed");

    if (!self.retakePic) {
        NSLog(@"retake no");
        self.retakePic = YES;
        self.imageTaken = YES;

        [self.takePicButton setImage:[UIImage imageNamed:@"takePicButton_Re"] forState:UIControlStateNormal];
        [picker takePicture];

        return;
    }else {
        NSLog(@"retake is yes");
        self.retakePic = NO;
        self.imageTaken = NO;

        picker = nil;
        [picker release];
        self.companyPopOverController = nil;
        [self.companyPopOverController release];
          [self setUpImagePicker];

        //button image, take
        [self.takePicButton setImage:[UIImage imageNamed:@"takePicButton"] forState:UIControlStateNormal];

        return;
    }

}
那么,如何确保我的应用程序只使用前置摄像头呢


谢谢

这是一个需要解决的问题,但是因为没有代表来完成你要找的任务,所以这样做就可以了

在ViewDidLoad中从PickerController注册通知(在这种情况下,因为您实现了自己的控件,所以可能需要设置自己的通知)

然后,当用户选择重新拍摄照片时,重新指定选择器使用前摄像头

  - (void)retakeImage:(NSNotification *)notification
  {
      self.pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
  }

希望这有帮助

这是一个需要解决的问题,但是因为没有代表来完成你要找的任务,所以这样做就可以了

在ViewDidLoad中从PickerController注册通知(在这种情况下,因为您实现了自己的控件,所以可能需要设置自己的通知)

然后,当用户选择重新拍摄照片时,重新指定选择器使用前摄像头

  - (void)retakeImage:(NSNotification *)notification
  {
      self.pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
  }
希望这有帮助