Showing camera within another view

Discussion in 'iPhone/iPad Programming' started by newtoiphonesdk, Apr 20, 2012.

  1. macrumors 6502a

    Joined:
    Jul 30, 2010
    #1
    I want to be able to present the camera on my view, but am having some issues. Is it better to use uiimagepickercontroller, or is there a better method? I simply am trying to emulate look of FaceTime, but it ceases if I try to alloc initwithframe, or instead of presenting the view in a modal controller adding as subview to current view. Is there a better way to do this?
     
  2. macrumors 6502

    Joined:
    Jan 20, 2008
    #2
    You can set an overlay view on UIImagePickerController. This way you can show the picker controller as you normally would but provide a custom overlay view that will shown on top.

    If you want more control than UIImagePickerController offers you'll need to look at AVFoundation, specifically the AVCaptureSession and AVCaptureVideoPreviewLayer.
     
  3. thread starter macrumors 6502a

    Joined:
    Jul 30, 2010
    #3
    I'm not talking about showing an overlay view...I'm talking about showing the camera in a small corner of the uiview, to emulate how FaceTime looks.
     
  4. macrumors 6502

    Joined:
    Jan 20, 2008
    #4
    You're going to have to dive into AVFoundation (and the classes I listed in my previous post) to pull that off. The UIImagPickerController is designed to be shown full screen - even with an overlay view.

    You should be able to use the AVCaptureVideoPreviewLayer to create a small view that displays video input. You'll want to read up on AVCaptureSession and check out some tutorials. It's not terribly difficult to configure a video input device with an AVCaptureVideoPreviewLayer but if you've never worked with AVFoundation it can quickly become overwhelming.
     

Share This Page