I am bringing up the camera with the following code from my ViewController:
- (void)viewDidLoad {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.sourceType = UIImagePickerControllerCameraDeviceFront;
self.imgPicker.delegate = self;
}
- (IBAction)grabCamera {
[self presentModalViewController:self.imgPicker animated:YES];
}
How can I make it so the camera by default uses the front camera of the iPhone4 and not the back camera? I tried DeviceFront to no avail.
Also, How can I add a subview (half sized) ontop of this camera after grabCamera is pressed?
If I have this subview in my MainWindow.xib I tried just saying addSubview after saying the presentModalViewController code but it didn't work... Do I need to create an NSTimer and load the addSubview after the camera display is fully presented or do I need to use something else (similar to z-index in CSS) The answer to the second question is imgPicker.cameraOverlayView = viewName;
Thanks all!
UIImagePickerControllerCameraDeviceFront
is not a valid enum for the sourceType
property. The sourceType
property defines whether you're using the camera or the photo library. You need to set the cameraDevice
property instead.
self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imgPicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
imgPicker.sourceType = .Camera
imgPicker.cameraDevice = .Front
imgPicker.sourceType = .camera
imgPicker.cameraDevice = .front
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With