Reputation: 27557
I'm trying to pick up iOS development, so I'm still a noob. I managed to copy and paste the camera controller (copied from here) and get it working.
However, I'm trying to create a spy camera app, so I don't want the screen to look like a camera. I want to cover it in black. I tried setting the brightness to 0, but that just makes everything dim. Setting the background to black didn't work either since the camera view is in the foreground. Is there a way to instantiate the camera controller and have the camera hardware active and somehow edit the view that comes along with it so that it doesn't show?
#import "EMCameraController.h"
@interface EMCameraController ()
@property (strong, nonatomic) IBOutlet UIImageView *camera;
@end
@implementation EMCameraController
@synthesize camera=_camera;
- (IBAction)showCamera:(id)sender {
[self startCameraControllerFromViewController: self
usingDelegate: self];
NSLog(@"done!");
}
- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
cameraUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeCamera];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
cameraUI.allowsEditing = NO;
cameraUI.delegate = delegate;
[controller presentModalViewController: cameraUI animated: NO];
cameraUI.view.backgroundColor = [UIColor blackColor]; //<-- doesn't work since camera view is in foreground
[[UIScreen mainScreen] setBrightness:0.0]; //<-- not working the way I want it.
return YES;
}
@end
Upvotes: 2
Views: 839
Reputation: 6942
You should use AVCapture*
approach. It allows to take images directly from camera. Take a look, for example, at this sample https://developer.apple.com/library/ios/samplecode/SquareCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011190-Intro-DontLinkElementID_2
Upvotes: 2