Christopher Weaver
Christopher Weaver

Reputation: 38

iOS 10 - UIImagePickerController for both Photos and Camera

When a user pulls up their sms app in iOS 10 and clicks on the camera icon, a pickerview comes up that allows users to either click on a photo from their library or snap a picture from the same view. Is there anything in Swift 3 that would allow third party applications to utilize this type of ImagePickerController? As of now I am only aware of the methods that allow apps to designate the photo library or camera exclusively as the source type.

Upvotes: 0

Views: 715

Answers (2)

Bayonetta
Bayonetta

Reputation: 116

I think iMessage's app doesn't use UIImagePickerController to implement that feature you metioned.

Use Photos.framework and AVFoundation.framework can create your expected UIViewController.

UIImagePickerController is just a simple high-level controller which is lack functions and less customization. It's hard to make complicated interfaces with it.

Upvotes: 3

Christian Abella
Christian Abella

Reputation: 5797

I have used ALCameraViewController in one of my apps before. It allows you to take photos, crop, and there is a button to pick images from the library. Just add the pod to your project.

Usage

To use this component couldn't be simpler. Add import ALCameraViewController to the top of you controller file.

In the viewController

let croppingEnabled = true
let cameraViewController = CameraViewController(croppingEnabled: croppingEnabled) { [weak self] image, asset in
    // Do something with your image here.
    // If cropping is enabled this image will be the cropped version

    self?.dismiss(animated: true, completion: nil)
}

present(cameraViewController, animated: true, completion: nil)

Upvotes: 1

Related Questions