Swift iOS 9 iPhone Camera Application

For product name, use IntellijSwiftCamera and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and make sure only iPhone is selected in Devices. Click Next.

P.S: Don’t forget to untick Include Unit Tests and Include UI Tests.

Open Main.storyboard. Set to Compact Width | Any Height.

Compact Width | Any Height

This is a very simple user interface consisting of an image view, a toolbar and two bar button items. (Don’t forget to set AutoLayout).

Camera ViewController

Create a new ViewController.

Cocoa Touch Class

UIViewController

Then make sure you attach this file into view controller in Identity inspector.

Identity inspector -UIViewController

Select the image view object in the view canvas, display the Assistant Editor panel. Ctrl-click on the image view object and drag to a position just below the class declaration line in the Assistant Editor. Release the line, and, in the resulting connection dialog, establish an outlet connection named imageView.

With the Assistant Editor still visible, establish action connections for the two buttons to methods named useCamera and useCameraRoll respectively (keeping mind that it may be necessary to click twice on each button to select it since the first click will typically select the toolbar parent object).

Action – userCamera

Action – useCameraRoll

Open CameraViewController.swift and update the with this code for useCamera and useCameraRoll functions.