How can I open camera inside my app controller.
I don't want to present built in camera controller.
I want to make my own camera sort of app.
Any suggestion or guide will be highly appreciated.
You can easily use UIImagePickerController
for this
UIImagePickerController *imagePickerController;
globally for the class@interface YourClassName : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePickerController setMediaTypes:@"public.image"]]; //specify image (not video)
[imagePickerController setShowsCameraControls:NO]; //hide default camera controls
[imagePickerController setNavigationBarHidden:YES];
[imagePickerController setToolbarHidden:YES];
[imagePickerController setAllowsEditing:NO];
[self.view addSubview:imagePickerController.view];
Use the takePicture
method for the UIImagePickerController
object like and assign it on a button action, like:
-(IBAction)btnTakePictureAct:(UIButton *)sender
{
[imagePickerController takePicture];
}
Use the delegate -imagePickerController:didFinishPickingMediaWithInfo:
to get the image.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = info[UIImagePickerControllerOriginalImage];
}
See this, get an idea, make your custom camera controls.
Refer: UIImagePickerController Apple Doc
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