Error: unrecognized selector sent to instance - Using Camera with OverlayView
<p>I'm having some trouble using the Camera with a custom overlay view.</p>

<p>This is the ViewController I use to set up and present the <code>UIImagePickerController</code>:</p>

<pre><code>import UIKit

class ViewController: UIViewController, CameraOverlayDelegate {

var imagePicker = UIImagePickerController()

@IBAction func pickImageButton(sender: AnyObject) {

    if UIImagePickerController.isSourceTypeAvailable(
            UIImagePickerControllerSourceType.Camera) {

        imagePicker = UIImagePickerController()
        imagePicker.sourceType = UIImagePickerControllerSourceType.Camera
        imagePicker.showsCameraControls = false

        let myCameraOverlayViewController = CameraOverlayViewController(
            nibName:"CameraOverlayView",
            bundle: nil)
        let customView = myCameraOverlayViewController.view
        customView.frame = imagePicker.view.frame
        imagePicker.cameraOverlayView = customView

        myCameraOverlayViewController.delegate = self
        presentViewController(imagePicker, animated: true, completion: nil)

    } else {
        print("No camera")
    }
}

func didTakePhoto(sender: CameraOverlayViewController) {
    print("Do something ...")
}
</code></pre>

<p>The custom overlay view is a *.xib-file and this is the CameraOverlayViewController I use:</p>

<pre><code>import UIKit

protocol CameraOverlayDelegate {
    func didTakePhoto(sender: CameraOverlayViewController)
}

class CameraOverlayViewController: UIViewController {

    var delegate: CameraOverlayDelegate! = nil

    @IBOutlet var myView: UIView!

    @IBAction func takePhotoButton(sender: AnyObject) {
        delegate.didTakePhoto(self)
    }
}
</code></pre>

<p>When I run the app I get an error (<code>-[UIView takePictureButton:]: unrecognized selector sent to instance</code>) as soon as I click the button which should call the <code>takePhotoButton(...)</code>-function.</p>

<p>I'm pretty new to Xcode, iOS developing and Swift ... in case the problem is obviously. ;)</p>

<p>Thanks in advance. </p>