首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未调用ELCImagePickerController委托方法

未调用ELCImagePickerController委托方法
EN

Stack Overflow用户
提问于 2014-08-25 04:54:35
回答 2查看 840关注 0票数 0

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

这是我的代码:

代码语言:javascript
复制
@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.")

    }
EN

回答 2

Stack Overflow用户

发布于 2015-03-17 03:25:25

您需要设置ImagePicker委托

代码语言:javascript
复制
imagePicker.imagePickerDelegate = self
票数 1
EN

Stack Overflow用户

发布于 2014-08-25 23:43:31

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25476255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档