title: Subview in Main View crash When assigning Image from AVFoundation to UIImageView
body: <p>I have created a custom <strong>AVFoundation</strong> camera and loaded into another view as subview with <strong>@IBDesignable</strong>, after the image is taken I would like to assign it to <code>UIImageView</code>, But when the button is pressed, the custom camera view (<code>UIView</code>) crash and move up in the screen, instead of assigning it to the <code>UIImageView</code>, This happens when the custom camera view load at the beginning, then when I load the custom camera view again, it will assign the image to the <code>UIImageView</code>.</p>
  
  <p><strong>Capture Image method:</strong></p>
  
  <pre><code>@IBAction func captureImage(sender: AnyObject) {
          if let stillOutput = self.captureImageOutput {
              // we do this on another thread so that we don't hang the UI
              dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
                  //find the video connection
                  var videoConnection : AVCaptureConnection?
                  for connecton in stillOutput.connections {
                      //find a matching input port
                      for port in connecton.inputPorts!{
                          if port.mediaType == AVMediaTypeVideo {
                              videoConnection = connecton as? AVCaptureConnection
                              break //for port
                          }
                      }
  
                      if videoConnection  != nil {
                          break// for connections
                      }
                  }
                  if videoConnection  != nil {
                      stillOutput.captureStillImageAsynchronouslyFromConnection(videoConnection){
                          (imageSampleBuffer : CMSampleBuffer!, _) in
  
                          let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageSampleBuffer)
                          let pickedImage: UIImage = UIImage(data: imageData, scale: 1.0)!
  
                          dispatch_async(dispatch_get_main_queue(), {
                              self.capturePhoto.image = pickedImage
                          })
                      }
                  }
              }
          }
  
      }
  </code></pre>
  
  <p>I have also tried the <strong><code>dispatch_sync</code></strong> and nothing load in the <strong>UIImageView</strong>,but the screen don't crash. </p>
  
  <pre><code>dispatch_sync(dispatch_get_main_queue(), {
        self.capturePhoto.image = pickedImage
  }) 
  </code></pre>