1

In my application, I have to use the front cam of the ipad and I have to take pics using front cam. I am automatically taking photos using the method [self.imagePickerController takePicture]; there is a count down and after the count down, the app automatically takes a picture. A user can take multiple pictures. When a user takes the first photo the app uses the front cam, but when the user takes the 2nd photo the application is using back cam and I only want to use the front cam. Please help. my code is given below:

- (IBAction)btnTakePic:(id)sender;
{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

        //[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

        //Set Notifications so that when user rotates phone, the orientation is reset to landscape.
        [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

        imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;


        imagePickerController.delegate = self;
        imagePickerController.showsCameraControls = NO;

        imagePickerController.cameraDevice= UIImagePickerControllerCameraDeviceFront;


        [imagePickerController setWantsFullScreenLayout:YES];

        [self presentModalViewController:imagePickerController animated:YES];
    }

    [NSTimer scheduledTimerWithTimeInterval:3.0
                                     target:self
                                   selector: @selector(targetMethod)
                                   userInfo:nil
                                    repeats:NO];
}
- (void)targetMethod
{
    [self.imagePickerController takePicture];

}
4

0 回答 0