How to use the camera inside my application controller

How to open the camera inside my application controller.

I do not want to introduce a built-in camera controller.
I want to create my own application for the camera.

Any suggestion or guide would be highly appreciated.

+6
source share
1 answer

You can easily use UIImagePickerController for this

  • Declare UIImagePickerController *imagePickerController; globally for class
  • Announce Protocols
    • @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 takePicture object and assign it to the button action, for example:

 -(IBAction)btnTakePictureAct:(UIButton *)sender { [imagePickerController takePicture]; } 

Use the -imagePickerController:didFinishPickingMediaWithInfo: delegate to get the image.

 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *image = info[UIImagePickerControllerOriginalImage]; } 

Look, get a view, do your custom camera control.
See UIImagePickerController Apple Doc

+2
source

All Articles