IOS before customizing camera

  • problem

    Not all uiimagepickercontrollers can take photos. The reasons are as follows:

    1. If the product is not integrated, how can we experience innovation

    2. How can the design reflect the intention

    3. Operation: how is the experience different from a certain treasure and a certain letter???

    4. Development: I am forced to be a big man!!! 1.2.3. If you put pressure on all levels, big factories can do it. Why can’t you

  • Thinking:

    Customization of cameras: what about the real-time scene in uiimagepicker controller?

    In general, avcapturesession + avcapturevideopreviewlayer is used

    Avcapturevideopreviewlayer inherits calayer and sets boundaries and frame to meet simple requirements

    But in such cases as horizontal and vertical screen switching, sharing of iPhone and iPad, view effect adjustment [after all, 1.2. The right to speak is generally greater than development], how can frame be constrained

    Each view has a layer attribute. The customized view layer is avcapturevideopreviewlayer, and the view constraint can be adjusted by changing the frame

  • Serve

    • Define a view

      @interface AVPreView : UIView
    • Set layerclass

      + (Class)layerClass {
          return [AVCaptureVideoPreviewLayer class];
    • For real-time scene, avcapturevideopreviewlayer needs to set a session

      //Set properties
      @property (nonatomic, strong) AVCaptureSession *session;
      // Getter & Setter
      - (AVCaptureSession *)session {
          return [(AVCaptureVideoPreviewLayer *)self.layer session];
      - (void)setSession:(AVCaptureSession *)session {
          [(AVCaptureVideoPreviewLayer *)self.layer setSession:session];
    • You need to set the focus and so on. At this time, you need to convert the touched point on the view to the position of the camera

          AVCaptureVideoPreviewLayer *layer = (AVCaptureVideoPreviewLayer *)self.layer;
          //Convert the click position on the screen into the position of the camera
          return [layer captureDevicePointOfInterestForPoint:point];
  • Game over. Code is no good, knock more.