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!

有帮助吗?

解决方案

use this below condition

if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) 
{
    imagePickerController.cameraDevice =  UIImagePickerControllerCameraDeviceRear;
}
else 
{
    imagePickerController.cameraDevice =  UIImagePickerControllerCameraDeviceFront;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top