Luke Irvin
Luke Irvin

Reputation: 1249

App opens with Rear Facing Camera launched

What's the best method of having the rear facing camera run when the app successfully launches?

I'd like my app to open with a modal view controller first that way the user can dismiss the camera if they do not wish to take a photo at that time.

Thanks!

EDIT:

I have figured this out... It's a lot easier than I was making it!

- (void)viewDidLoad
{
    self.UIPicker = [[UIImagePickerController alloc] init];
    self.UIPicker.delegate = self;
    self.UIPicker.sourceType = UIImagePickerControllerSourceTypeCamera;

    [self launchCamera];
}

- (void)launchCamera
{
    if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear])
    {
        self.UIPicker.cameraDevice =  UIImagePickerControllerCameraDeviceRear;
        [self presentViewController:self.UIPicker animated:NO completion:nil];
    }
    else
    {
        self.UIPicker.cameraDevice =  UIImagePickerControllerCameraDeviceFront;
        [self presentViewController:self.UIPicker animated:NO completion:nil];
    }
}

// image picker delegate code here

Another question though:

I am using a custom overlay, but the native "shutter" graphic still shows. How can this be removed or hidden?

Thanks!

Upvotes: 1

Views: 224

Answers (1)

D-eptdeveloper
D-eptdeveloper

Reputation: 2430

use this below condition

if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) 
{
    imagePickerController.cameraDevice =  UIImagePickerControllerCameraDeviceRear;
}
else 
{
    imagePickerController.cameraDevice =  UIImagePickerControllerCameraDeviceFront;
}

Upvotes: 2

Related Questions