Most of the time we require Picking Image from Gallery and Camera iPhone Swift. iOS provides the UIImagePickerController which is helpful in picking images from gallery or to take photos using the built-in camera of an iOS device.
In our last tutorial we learn how to use here.. In todays tutorial we will display image in UIImageView and use UIButton to initiate camera or to show gallery.
Create New Project : ImaGer
Open Xcode start a new project > name it to Imager. Select Language Swift. I’m using Swift 2.1 and Xcode 7.2.1.
Working on UI of Project.
We will user 2 buttons one to pick image from gallery other to open camera and click pic. And one image view to display image clicked/picked. I have used constraints in this project.
Creating Outlets on controller.
Press Control and drag the object on ViewController to create its outlet. Do it for all 3 objects.We will create button actions on View
Picking Image From Gallery.
Add UINavigationControllerDelegate,UIImagePickerControllerDelegate to your ViewController. UIimagePickerController is the user interface for managing the user interaction with the camera or with the gallery.
Create an object for your UIImagePickerController.