Bar Button Item not working after dismissing UIImagePickerController
<p>I have a Bar Button Item that triggers an alert that asks the user whether they want to take a photo or pick an image from their library. Upon picking photo library, I instantiate a UIImagePickerController so they select a photo.</p>

<p>My problem is that after picking an image and dismissing the view controller, the app returns to the original view controller, image is displayed in the outlet properly, but the button that worked before will not trigger the alert to select an image again (nor will anything print to console).</p>

<pre><code>@IBAction func pickAnImage(sender: AnyObject) {
    selectImageSourceAlert()
}

func selectImageSourceAlert() {
    let alert = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
    let userLibrary = UIAlertAction(title: "Photo Library", style: .Default) {
        _ in
        self.presentImagePicker(pickerStyle: .PhotoLibrary)
    }
    let useCamera = UIAlertAction(title: "Camera", style: .Default) {
        _ in
        let x = UIImagePickerController.isSourceTypeAvailable(.Camera)
        print(x)
        if x {
            self.presentImagePicker(pickerStyle: .Camera)
        } else {
            print("No camera available")
        }
    }

    let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)

    alert.addAction(userLibrary)
    alert.addAction(useCamera)
    alert.addAction(cancelAction)

    presentViewController(alert, animated: true, completion: nil)
}

func presentImagePicker(pickerStyle style: UIImagePickerControllerSourceType) {
    let imagePicker = UIImagePickerController()
    imagePicker.delegate = self
    imagePicker.sourceType = style
    imagePicker.allowsEditing = true

    self.presentViewController(imagePicker, animated: true, completion: nil)
}

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
    self.dismissViewControllerAnimated(true, completion: nil)

    if let image = info["UIImagePickerControllerEditedImage"] as? UIImage {
        imagePickerView.image = image
    }
}
</code></pre>

<p>After a few days I'm still not able to figure it out. I have found that when I remove the "if let image = info" bit, and forgo assigning the image to the imagePickerView outlet, the button works after dismissing the view controller. The button also works if I cancel at any point before selecting an image. It only doesn't work when I assign the image to the outlet.</p>

<p>Thanks in advance for any help!</p>

<p>EDIT: I've noticed when I added a second button in the upper right corner and assigned it to the same action, it works even after assigning a photo. The first Bar Button Item in the bottom left corner will only work while there is no image assigned to the imageView. Not sure why as it isn't covered by the imageView in any way. Added red background color for clarity.</p>

<p><a href="http://i.stack.imgur.com/ihFAf.png" rel="nofollow">Simulation Image</a></p>