繁体   English   中英

ELCImagePickerController委托方法未调用

[英]ELCImagePickerController delegate methods not called

我正在尝试使用ELCImagePickerController构建应用程序。 我发现可以选择多张图片。 但是,未调用ELCImagePickerController委托方法。

这是我的代码:

@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.")

    }

您需要设置ImagePicker委托

imagePicker.imagePickerDelegate = self

是否曾经调用过您的NSLog语句? 我在结尾的闭包语法中注意到的一件事是,您使用的是类型名称,而不是该类型的变量。 例如,您正在...中编写UIAlertAction in ... alertAction in ... 您应该提供在闭包中使用的名称,而不是类型本身。 如果关闭的其余部分未执行,则永远不会设置委托,因此永远不会调用委托方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM