iPhone sdk - Use a custom camera

后端 未结 2 1955
没有蜡笔的小新
没有蜡笔的小新 2020-12-30 17:16

I\'m developing an app that needs to take two pictures in a row. I\'m currently using the iPhone camera but :

  • I would like to NOT have the cancel button on the
相关标签:
2条回答
  • 2020-12-30 17:53

    Create a UIImagePickerController from code, adjust its properties, add an overlay onto it, and with you controller, control whatever you want on that overlay: custom controls, overlaying images, etc...

    That gives something like this :

    self.picker = [[UIImagePickerController alloc] init];
    self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    self.picker.showsCameraControls = NO;
    self.picker.navigationBarHidden = YES;
    self.picker.toolbarHidden = YES;
    self.picker.wantsFullScreenLayout = YES;
    
    // Insert the overlay
    self.overlay = [[OverlayViewController alloc] initWithNibName:@"Overlay" bundle:nil];
    self.overlay.pickerReference = self.picker;
    self.picker.cameraOverlayView = self.overlay.view;
    self.picker.delegate = self.overlay;
    
    [self presentModalViewController:self.picker animated:NO];
    

    OverlayViewController is the controller that you must write to control everything you add onto the overlay.

    pickerReference is a property you can keep to send orders to the camera. For example, you could call the following from an IBAction coming from a UIButton placed onto the overlay:

    [self.pickerReference takePicture];
    
    0 讨论(0)
  • 2020-12-30 17:58

    The easiest way to do it is to use UIImagePickerController with showsCameraControls set to NO and a custom view set in cameraOverlayView; this view can have whatever buttons you need on it. When touched, the button should call takePicture on the image picker, and when you're done just use dismissModalViewControllerAnimated: to dismiss the picker.

    0 讨论(0)
提交回复
热议问题