0

I'm trying to build an app using ELCImagePickerController. I found that I could select multiple pictures. However, the ELCImagePickerController delegate method was not called.

This is my code:

@IBAction func uploadImages(sender: AnyObject) {

        // Create the alert controller
        //var alertController = UIAlertController(title: "", message: "", preferredStyle: .Alert)
        var alertController = UIAlertController(title: nil, message: nil, preferredStyle: .Alert)
        // Create the actions
        var takeAction = UIAlertAction(title: "Take Photos", style: UIAlertActionStyle.Default) {
            UIAlertAction in
            NSLog("Take Photos Pressed")

        }

        var selectAction = UIAlertAction(title: "Select Photos", style: UIAlertActionStyle.Default) {
            UIAlertAction in
            NSLog("Select photos Pressed")
            var imagePicker = ELCImagePickerController(imagePicker: ())
            imagePicker.maximumImagesCount = 2
            imagePicker.returnsOriginalImage = false
            imagePicker.returnsImage = true
            imagePicker.onOrder = true
            imagePicker.delegate = self

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

        }

        var cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
            UIAlertAction in
            NSLog("Cancel Pressed")
        }

        // Add the actions
        alertController.addAction(takeAction)
        alertController.addAction(selectAction)
        alertController.addAction(cancelAction)

        // Present the controller
        self.presentViewController(alertController, animated: true, completion: nil)
        }
    }

func elcImagePickerController(picker: ELCImagePickerController!, didFinishPickingMediaWithInfo info:[AnyObject]!) {

                NSLog("controller executed.")

    }
NobodyNada
  • 7,529
  • 6
  • 44
  • 51
Alex Jiang
  • 91
  • 1
  • 4
  • 1
    Hi, I have the same issue. Did you fine a solution? – Fogia Feb 01 '15 at 00:40
  • Also having the same issue. - Edited- Actually, I realized the delegate method was being called (after I clicked 'Done'), but there is just no interface for seeing which photos are selected. – Adrienne Jun 04 '15 at 03:44

2 Answers2

1

You need to set the ImagePicker delegate

imagePicker.imagePickerDelegate = self
Andy
  • 49,085
  • 60
  • 166
  • 233
Dhanu A
  • 207
  • 3
  • 1
0

Are your NSLog statements ever getting called? One thing I notice in your trailing closure syntax is that you're using the type name versus a variable of that type. For instance, you're writing UIAlertAction in ... vs alertAction in .... You should be providing a name to be used within the closure rather than the type itself. If the rest of the closure is not executing, then the delegate is never being set, and therefore delegate methods are never called.

BJ Miller
  • 1,536
  • 12
  • 16