November 12, 2021
•
When it comes to building an app to take pictures and capture videos in iOS, Apple provides two different approaches: UIImagePickerController and AVCaptureSession.
UIImagePickerController is the easiest way to get up and running since you can have a working solution with a few lines of code. However, this simplicity comes at a cost: UI customization or adding functionalities to the camera (e.g., tap to focus) has its difficulties.
On the other hand, AVCaptureSession, part of the AVFoundation framework, enables more customization flexibility, but it's harder to configure and manage. Its complexity and known headaches associated with its usage can drive some developers away.
We built Camera Manager to create custom camera views using the best qualities of these tools: better interaction with AVCaptureSession and the flexibility of AVFoundation while hiding all the nitty-gritty details from the developer.
With Camera Manager, the developer can create beautiful custom UIs and achieve awesome results with photos, without reinventing the wheel.
Camera Manager provides a simple custom iOS camera view to capture photos and record videos easily, with the following features:
To provide all these capabilities, Camera Manager uses AVCaptureSession
, which according to Apple is: "an object that manages capture activity and coordinates the flow of data from input devices to capture."
Instead of manually creating a capture session, obtaining and configuring the necessary capture devices, creating inputs using the capture devices, and configuring a video/photo output object to process captured videos/images, the developer only needs to add the preview layer to the desired view.
All the changes to the AVCaptureDevice
, such as setting the flash mode and switching between the front and back cameras, are safely done and configured by Camera Manager.
And then when capturing an image:
Also, to start and stop the recording of a video:
As demonstrated, Camera Manager provides the flexibility from AVCaptureSession while maintaining the simplicity from UIImagePickerViewController.
There are some alternatives available, but Camera Manager has a few strong points that make it an exceptional choice:
We encourage you to try it. Camera Manager has an example app that you can run on your device. You'll need a real device to run it, due to the use of AVFoundation camera API's which are unavailable on the iOS simulator.
Found this article useful? You might like these ones too!
Senior Developer at Imaginary Cloud, specialising in creating innovative software solutions, passionate about technology and coding excellence.
People who read this post, also found these interesting: