Attaching camera or gallery images to Swift

3

Good morning, I'm developing an application in Swift, but I'm new to the language and I do not know a few things, I'd like to know how I attach the images from my gallery or open the camera to take a picture. >

Thank you in advance.

    
asked by anonymous 04.09.2017 / 14:48

1 answer

0

You can make a giant code on hand or use a pod, which is what I recommend. I have already used the ALCameraViewController pod, which makes it possible to take photos as well as choose from the gallery. You can find his github here:

link

Steps to use:

1) Add in your podfile:

pod 'ALCameraViewController'

2) Import into your file that will call the view controller of the camerâ pod, with the following line:

import ALCameraViewController

3) When calling the camera view controller, use the following code:

let cameraViewController = CameraViewController { [weak self] image, asset in
    // A variável image que você recebe aqui vai ter a imagem que o usuário escolheu. Fique atento para o caso que ele cancela a escolha da imagem.
    self?.dismiss(animated: true, completion: nil)
}

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

For more swif tips, iOS development and entrepreneurship subscribe to my youtube channel: link

    
06.09.2017 / 21:24